From 21895f3301288a6de1fc7fcc01303bc7e81002a0 Mon Sep 17 00:00:00 2001 From: Philipp Panzer <philipp.panzer@fau.de> Date: Tue, 5 Mar 2019 12:17:46 +0100 Subject: [PATCH] fix some stuff in the test suite for compatibility with new interface --- bin/dhallish | 4 ++-- lib/dhallish.rb | 2 +- tests/test.rb | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/dhallish b/bin/dhallish index fba0a1e..8be03d7 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 0680fdf..e35cf09 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 47f32b1..664a1ea 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 -- GitLab