From 69d125b667c0f1b626aa49a7a0538a7d0d66c5c9 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Thu, 23 Jan 2020 14:29:04 +0100 Subject: [PATCH] fix evaluate-value and added tests --- src/bin/cli.ml | 2 +- src/bin/expect_tests/eval_value_tests.ml | 10 ++++++++++ src/test/contracts/evaluation_tests.ligo | 11 +++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/bin/expect_tests/eval_value_tests.ml create mode 100644 src/test/contracts/evaluation_tests.ligo diff --git a/src/bin/cli.ml b/src/bin/cli.ml index edb571cd0..42cecfd4f 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -374,7 +374,7 @@ let evaluate_value = let%bind compiled = Compile.Of_mini_c.aggregate_and_compile_expression mini_c exp in let%bind options = Run.make_dry_run_options {predecessor_timestamp ; amount ; sender ; source } in let%bind michelson_output = Run.run_no_failwith ~options compiled.expr compiled.expr_ty in - let%bind simplified_output = Uncompile.uncompile_typed_program_entry_function_result typed_prg entry_point michelson_output in + let%bind simplified_output = Uncompile.uncompile_typed_program_entry_expression_result typed_prg entry_point michelson_output in ok @@ Format.asprintf "%a\n" Ast_simplified.PP.expression simplified_output in let term = diff --git a/src/bin/expect_tests/eval_value_tests.ml b/src/bin/expect_tests/eval_value_tests.ml new file mode 100644 index 000000000..ef4ccd1bd --- /dev/null +++ b/src/bin/expect_tests/eval_value_tests.ml @@ -0,0 +1,10 @@ +open Cli_expect + +let%expect_test _ = + run_ligo_good [ "evaluate-value" ; "../../test/contracts/evaluation_tests.ligo" ; "a" ] ; + [%expect {| + {foo = +0 , bar = "bar"} |} ]; + + run_ligo_good [ "evaluate-value" ; "../../test/contracts/evaluation_tests.ligo" ; "b" ] ; + [%expect {| + 2 |} ] \ No newline at end of file diff --git a/src/test/contracts/evaluation_tests.ligo b/src/test/contracts/evaluation_tests.ligo new file mode 100644 index 000000000..b531d4a7b --- /dev/null +++ b/src/test/contracts/evaluation_tests.ligo @@ -0,0 +1,11 @@ +type myrec is record + foo : nat; + bar : string; +end; + +const a : myrec = record + foo = 0n; + bar = "bar"; +end; + +const b : int = 2 ; \ No newline at end of file