diff --git a/lib/types.rb b/lib/types.rb index 5df81082bebef53549134173af426b82de49e2a1..0224f9ed29b35ff25ac0847dcd4c3aeb5b5abc91 100644 --- a/lib/types.rb +++ b/lib/types.rb @@ -257,6 +257,8 @@ module Dhallish "[#{ dhallval.map{ |val| to_json(val) }.join(", ") }]" when Hash "{#{ dhallval.map{ |key, val| "\"#{escape_str(key)}\": #{ to_json(val) }" }.join(", ") }}" + when nil + "null" else "\"Dhallish-Internal: #{escape_str(dhallval.inspect)}\"" end diff --git a/tests/test.rb b/tests/test.rb index 664a1ea38e72f3361ef3fec086f2c473507cece7..9dd57a0a4a761401cbda8a81c60eaac0064cc461 100755 --- a/tests/test.rb +++ b/tests/test.rb @@ -90,18 +90,12 @@ dhallfiles.each { |file| dhallish = Dhallish::Dhallish.new val = (dhallish.evaluate `cat #{file}`)[0] - if !val.nil? - result = JSON.parse(Dhallish::to_json val) - assert("Testing Dhall-Compability for `#{file}`") { expected == result } - end + result = JSON.parse(Dhallish::to_json val) + assert("Testing Dhall-Compability for `#{file}`") { expected == result } rescue print_msg(file, false) else - if val.nil? - print_msg("#{file} - parsing error", false) - else - print_msg(file, true) - end + print_msg(file, true) end } @@ -114,18 +108,12 @@ dhallfiles.each { |file| expected = JSON.parse(`cat #{expected_file_name}`) dhallish = Dhallish::Dhallish.new - val = dhallish.evaluate `cat #{file}` - if !val.nil? - result = JSON.parse(val.to_json) - assert("Testing Dhall-Compability for `#{file}`") { expected == result } - end + val = (dhallish.evaluate `cat #{file}`)[0] + result = JSON.parse(Dhallish::to_json val) + assert("Testing Dhall-Compability for `#{file}`") { expected == result } rescue print_msg(file, false) else - if val.nil? - print_msg("#{file} - parsing error", false) - else - print_msg(file, true) - end + print_msg(file, true) end }