From bbf6b7b8605a98a86eed9bc1db76dafc32230b87 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Fri, 6 Dec 2019 19:42:41 +0100 Subject: [PATCH] =?UTF-8?q?ss=C3=A9ssaoupa=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/contracts/high-order.ligo | 2 ++ src/test/integration_tests.ml | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/test/contracts/high-order.ligo b/src/test/contracts/high-order.ligo index 107cbd9ff..5540d6f99 100644 --- a/src/test/contracts/high-order.ligo +++ b/src/test/contracts/high-order.ligo @@ -48,3 +48,5 @@ function foobar5 (const i : int) : int is function goo (const i : int) : int is foo(i); } with higher3(i,foo,goo) + +function foobar6 (const i : int) : (int->int) is f \ No newline at end of file diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 201c0ebd3..cd6aae92d 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -184,6 +184,26 @@ let higher_order () : unit result = let%bind _ = expect_eq_n_int program "foobar3" make_expect in let%bind _ = expect_eq_n_int program "foobar4" make_expect in let%bind _ = expect_eq_n_int program "foobar5" make_expect in + + + let%bind (typed_arg,_) = Compile.Of_simplified.compile_expression + ~env:(Ast_typed.Environment.full_empty) ~state:(Typer.Solver.initial_state) (e_int 1) in + let%bind mini_c_arg = Compile.Of_typed.compile_expression typed_arg in + let%bind compiled_arg = Compile.Of_mini_c.compile_expression mini_c_arg in + let%bind arg_michelson = Ligo.Run.Of_michelson.evaluate_expression compiled_arg.expr compiled_arg.expr_ty in + + let%bind michelson = Compile.Wrapper.typed_to_michelson_fun program "foobar6" in + let%bind _michelson_output1 = Ligo.Run.Of_michelson.run_function michelson.expr michelson.expr_ty arg_michelson false in (* foobar6(1) = f *) + + let%bind _michelson_output1 = Ligo.Run.Of_michelson.ex_value_ty_to_michelson _michelson_output1 in + let%bind expr_ty = Compiler.Type.Ty.type_ (T_function (Mini_c.t_int,Mini_c.t_int)) in + let%bind _michelson_output2 = Ligo.Run.Of_michelson.run_function _michelson_output1 expr_ty arg_michelson false in (* f(1) = 1*) + + let%bind mini_c_un = Compiler.Uncompiler.translate_value _michelson_output2 in + let%bind typed_un = Transpiler.untranspile mini_c_un (Ast_typed.t_int ()) in + let%bind _simplified_output = Typer.untype_expression typed_un in + let%bind () = Ast_simplified.Misc.assert_value_eq (_simplified_output , e_int 1) in + ok () let higher_order_mligo () : unit result =