diff --git a/bin/dhallish b/bin/dhallish index fba0a1e62ba8cf3b7256073fa7a9d9f164069165..8be03d74879d60567658436fb8f1151151d59683 100755 --- a/bin/dhallish +++ b/bin/dhallish @@ -12,10 +12,10 @@ end input = $stdin.read begin - output = dhall.evaluate(input)[0].to_json + output = dhall.evaluate(input)[0] rescue DhallError => err STDERR.puts err exit! 1 else - puts output + puts Dhallish::to_json output end diff --git a/lib/dhallish.rb b/lib/dhallish.rb index 0680fdf2e15ca664fc302dfb61c0deee2a8790e2..e35cf093e7d923cf602cb3a07d77c78094a1721b 100644 --- a/lib/dhallish.rb +++ b/lib/dhallish.rb @@ -32,7 +32,7 @@ module Dhallish ast = treetopast.to_node nil type = ast.compute_type typectx - puts type + #puts type return [ast.evaluate(ctx), type] end diff --git a/tests/test.rb b/tests/test.rb index 47f32b1565aa75a43b29f7ae4a41cd991bc397de..664a1ea38e72f3361ef3fec086f2c473507cece7 100755 --- a/tests/test.rb +++ b/tests/test.rb @@ -34,7 +34,7 @@ positive_tests = { "identity with type parameter": ["let f = \\(t : Type) -> \\(x : t) -> x in (f : forall(t : Type) -> t -> t) Natural 2", 2], "function with two type parameters": ["let f = \\(t : Type) -> \\(u : Type) -> \\(x : t) -> \\(y : u) -> x in (f : forall(t : Type) -> forall(u : Type) -> t -> u -> t) Natural Integer 1 -1 ", 1 ], "fallback for file import": ["let x = ./foobarfoobar.dhall as Text ? 1 in x", 1], - "more type annotation": [ "let f = \(a: Type) -> \(l: List a) -> \(x: a) -> x in (f: forall(b: Type) -> forall(l: List b) -> b -> b) Natural [1, 2, 3] 5", 5 ] + "more type annotation": [ "let f = \\(a: Type) -> \\(l: List a) -> \\(x: a) -> x in (f: forall(b: Type) -> forall(l: List b) -> b -> b) Natural [1, 2, 3] 5", 5 ] } negative_tests = { @@ -54,8 +54,8 @@ positive_tests.each { |name, arr| begin dhallish = Dhallish::Dhallish.new - res = dhallish.evaluate code - assert("Testing Dhallish: `#{code}`") { res.val == expected } + res = (dhallish.evaluate code)[0] + assert("Testing Dhallish: `#{code}`") { res == expected } rescue print_msg(name, false) else @@ -69,7 +69,7 @@ negative_tests.each { |name, arr| begin dhallish = Dhallish::Dhallish.new - res = dhallish.evaluate code + dhallish.evaluate code rescue print_msg(name, true) else @@ -89,9 +89,9 @@ dhallfiles.each { |file| expected = JSON.parse(`cat #{expected_file_name}`) dhallish = Dhallish::Dhallish.new - val = dhallish.evaluate `cat #{file}` + val = (dhallish.evaluate `cat #{file}`)[0] if !val.nil? - result = JSON.parse(val.to_json) + result = JSON.parse(Dhallish::to_json val) assert("Testing Dhall-Compability for `#{file}`") { expected == result } end rescue