diff --git a/src/test/coase_tests.ml b/src/test/coase_tests.ml index 967130f3d..874712849 100644 --- a/src/test/coase_tests.ml +++ b/src/test/coase_tests.ml @@ -10,7 +10,8 @@ let get_program = fun () -> match !s with | Some s -> ok s | None -> ( - let%bind program = type_file "./contracts/coase.ligo" in + let%bind (program , state) = type_file "./contracts/coase.ligo" in + let () = Typer.Solver.discard_state state in s := Some program ; ok program ) diff --git a/src/test/heap_tests.ml b/src/test/heap_tests.ml index 2b66de488..4fe87b4b3 100644 --- a/src/test/heap_tests.ml +++ b/src/test/heap_tests.ml @@ -8,7 +8,8 @@ let get_program = fun () -> match !s with | Some s -> ok s | None -> ( - let%bind program = type_file "./contracts/heap-instance.ligo" in + let%bind (program , state) = type_file "./contracts/heap-instance.ligo" in + let () = Typer.Solver.discard_state state in s := Some program ; ok program ) diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 7a50ad29b..a0d93c782 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -3,8 +3,14 @@ open Test_helpers open Ast_simplified.Combinators -let mtype_file ?debug_simplify ?debug_typed = Ligo.Compile.Of_source.type_file ?debug_simplify ?debug_typed (Syntax_name "cameligo") -let type_file = Ligo.Compile.Of_source.type_file (Syntax_name "pascaligo") +let mtype_file ?debug_simplify ?debug_typed f = + let%bind (typed , state) = Ligo.Compile.Of_source.type_file ?debug_simplify ?debug_typed (Syntax_name "cameligo") f in + let () = Typer.Solver.discard_state state in + ok typed +let type_file f = + let%bind (typed , state) = Ligo.Compile.Of_source.type_file (Syntax_name "pascaligo") f in + let () = Typer.Solver.discard_state state in + ok typed let type_alias () : unit result = let%bind program = type_file "./contracts/type-alias.ligo" in @@ -212,9 +218,9 @@ let bytes_arithmetic () : unit result = let%bind () = expect_eq program "slice_op" tata at in let%bind () = expect_fail program "slice_op" foo in let%bind () = expect_fail program "slice_op" ba in - let%bind b1 = Run.Of_simplified.run_typed_program program "hasherman" foo in + let%bind b1 = Run.Of_simplified.run_typed_program program Typer.Solver.initial_state "hasherman" foo in let%bind () = expect_eq program "hasherman" foo b1 in - let%bind b3 = Run.Of_simplified.run_typed_program program "hasherman" foototo in + let%bind b3 = Run.Of_simplified.run_typed_program program Typer.Solver.initial_state "hasherman" foototo in let%bind () = Assert.assert_fail @@ Ast_simplified.Misc.assert_value_eq (b3 , b1) in ok () diff --git a/src/test/test_helpers.ml b/src/test/test_helpers.ml index 9eee8adc0..d7650a343 100644 --- a/src/test/test_helpers.ml +++ b/src/test/test_helpers.ml @@ -38,7 +38,7 @@ let expect ?input_to_value ?options program entry_point input expecter = let content () = Format.asprintf "Entry_point: %s" entry_point in error title content in trace run_error @@ - Ligo.Run.Of_simplified.run_typed_program ?input_to_value ?options program entry_point input in + Ligo.Run.Of_simplified.run_typed_program ?input_to_value ?options program Typer.Solver.initial_state entry_point input in expecter result let expect_fail ?options program entry_point input = @@ -49,7 +49,7 @@ let expect_fail ?options program entry_point input = in trace run_error @@ Assert.assert_fail - @@ Ligo.Run.Of_simplified.run_typed_program ?options program entry_point input + @@ Ligo.Run.Of_simplified.run_typed_program ?options program Typer.Solver.initial_state entry_point input let expect_eq ?input_to_value ?options program entry_point input expected = diff --git a/src/test/typer_tests.ml b/src/test/typer_tests.ml index b22fb01db..9b7007c9b 100644 --- a/src/test/typer_tests.ml +++ b/src/test/typer_tests.ml @@ -11,7 +11,9 @@ let int () : unit result = let pre = e_int 32 in let open Typer in let e = Environment.full_empty in - let%bind post = type_expression e pre in + let state = Typer.Solver.initial_state in + let%bind (post , new_state) = type_expression e state pre in + let () = Typer.Solver.discard_state new_state in let open! Typed in let open Combinators in let%bind () = assert_type_value_eq (post.type_annotation, t_int ()) in @@ -19,12 +21,14 @@ let int () : unit result = module TestExpressions = struct let test_expression ?(env = Typer.Environment.full_empty) + ?(state = Typer.Solver.initial_state) (expr : expression) (test_expected_ty : Typed.tv) = let pre = expr in let open Typer in let open! Typed in - let%bind post = type_expression env pre in + let%bind (post , new_state) = type_expression env state pre in + let () = Typer.Solver.discard_state new_state in let%bind () = assert_type_value_eq (post.type_annotation, test_expected_ty) in ok () diff --git a/src/test/vote_tests.ml b/src/test/vote_tests.ml index 683169ee2..645ccf758 100644 --- a/src/test/vote_tests.ml +++ b/src/test/vote_tests.ml @@ -8,9 +8,9 @@ let get_program = fun () -> match !s with | Some s -> ok s | None -> ( - let%bind program = type_file "./contracts/vote.mligo" in - s := Some program ; - ok program + let%bind (program , state) = type_file "./contracts/vote.mligo" in + s := Some (program , state) ; + ok (program , state) ) open Ast_simplified @@ -39,8 +39,8 @@ let vote str = e_constructor "Vote" vote let init_vote () = - let%bind program = get_program () in - let%bind result = Ligo.Run.Of_simplified.run_typed_program program "main" (e_pair (vote "Yes") (init_storage "basic")) in + let%bind (program , state) = get_program () in + let%bind result = Ligo.Run.Of_simplified.run_typed_program program state "main" (e_pair (vote "Yes") (init_storage "basic")) in let%bind (_ , storage) = extract_pair result in let%bind storage' = extract_record storage in let votes = List.assoc "candidates" storage' in