M .builds.dhall/debian-stable.dhall => .builds.dhall/debian-stable.dhall +1 -0
@@ 15,6 15,7 @@
cd dhall-ruby
rubocop
bundle install --path="../.gems"
+ test/normalization/gen
bundle exec ruby -Ilib test/test_binary.rb
''
}
M lib/dhall/ast.rb => lib/dhall/ast.rb +2 -2
@@ 332,7 332,7 @@ module Dhall
end
def map_subexpressions(&block)
- self.class.new(Hash[*@record.map { |k, v| [k, block[v]] }])
+ self.class.new(Hash[@record.map { |k, v| [k, block[v]] }])
end
def deep_merge_type(other)
@@ 372,7 372,7 @@ module Dhall
end
def map_subexpressions(&block)
- self.class.new(Hash[*@record.map { |k, v| [k, block[v]] }])
+ self.class.new(Hash[@record.map { |k, v| [k, block[v]] }])
end
def fetch(k, default=nil, &block)
M lib/dhall/builtins.rb => lib/dhall/builtins.rb +2 -2
@@ 22,7 22,7 @@ module Dhall
class Double_show < Builtin
def call(arg)
if arg.is_a?(Double)
- Text.new(value: "\"#{arg.to_s}\"")
+ Text.new(value: arg.to_s)
else
super
end
@@ 32,7 32,7 @@ module Dhall
class Integer_show < Builtin
def call(arg)
if arg.is_a?(Integer)
- Text.new(value: "\"#{arg.to_s}\"")
+ Text.new(value: arg.to_s)
else
super
end
M lib/dhall/normalize.rb => lib/dhall/normalize.rb +7 -6
@@ 53,12 53,13 @@ module Dhall
end
def substitute(svar, with_expr)
- with_expr = with_expr.shift(1, var, 0)
- if var == svar.name
- super(svar.with(index: svar.index + 1), with_expr)
- else
- super(svar, with_expr)
- end
+ with(
+ type: type.substitute(svar, with_expr),
+ body: body.substitute(
+ var == svar.name ? svar.with(index: svar.index + 1) : svar,
+ with_expr.shift(1, var, 0)
+ )
+ )
end
end
M test/normalization/beta/DoubleShowValueB.dhallb => test/normalization/beta/DoubleShowValueB.dhallb +1 -1
@@ 1,1 1,1 @@
-�e5.0.0�e"1.2">
\ No newline at end of file
+�e5.0.0�c1.2<
\ No newline at end of file
M test/normalization/beta/IntegerShow-12B.dhallb => test/normalization/beta/IntegerShow-12B.dhallb +1 -1
@@ 1,1 1,1 @@
-�e5.0.0�e"-12">
\ No newline at end of file
+�e5.0.0�c-12<
\ No newline at end of file
M test/normalization/beta/IntegerShow12B.dhallb => test/normalization/beta/IntegerShow12B.dhallb +1 -1
@@ 1,1 1,1 @@
-�e5.0.0�e"+12">
\ No newline at end of file
+�e5.0.0�c+12<
\ No newline at end of file
A test/normalization/dhall-encode => test/normalization/dhall-encode +3 -0
@@ 0,0 1,3 @@
+#!/bin/sh
+
+dhall encode < "$1" > "$1"b
A test/normalization/gen => test/normalization/gen +5 -0
@@ 0,0 1,5 @@
+#!/bin/sh
+
+cp -r "$(git root)"/dhall-lang/tests/normalization/success "$(git root)"/test/normalization/standard
+cd "$(git root)"/test/normalization/standard
+find . -name '*.dhall' -exec "$(git root)"/test/normalization/dhall-encode '{}' \;
A test/normalization/standard/.gitignore => test/normalization/standard/.gitignore +2 -0
@@ 0,0 1,2 @@
+*.dhall
+*.dhallb
M test/test_normalization.rb => test/test_normalization.rb +18 -3
@@ 8,14 8,29 @@ require "dhall/binary"
require "dhall/normalize"
DIRPATH = Pathname.new(File.dirname(__FILE__))
-TESTS = DIRPATH + "normalization/beta/"
+UNIT = DIRPATH + "normalization/beta/"
+STANDARD = DIRPATH + 'normalization/standard/'
class TestParser < Minitest::Test
- Pathname.glob(TESTS + "*A.dhallb").each do |path|
+ Pathname.glob(UNIT + "*A.dhallb").each do |path|
test = path.basename("A.dhallb").to_s
define_method("test_#{test}") do
assert_equal(
- Dhall.from_binary(TESTS + "#{test}B.dhallb"),
+ Dhall.from_binary(UNIT + "#{test}B.dhallb"),
+ Dhall.from_binary(path.read).normalize
+ )
+ end
+ end
+
+ Pathname.glob(STANDARD + "**/*A.dhallb").each do |path|
+ test = path.relative_path_from(STANDARD).to_s.sub(/A\.dhallb$/, '')
+ next if test =~ /prelude\//
+ next if test =~ /remoteSystems/
+ next if test =~ /constructorsId$/
+ next if test =~ /multiline\//
+ define_method("test_#{test.gsub(/\//, '_')}") do
+ assert_equal(
+ Dhall.from_binary(STANDARD + "#{test}B.dhallb"),
Dhall.from_binary(path.read).normalize
)
end