tests build (but fail when running, as expected)
This commit is contained in:
parent
3bbb8bfd8b
commit
38f9b0ba0b
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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 ()
|
||||
|
||||
|
@ -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 =
|
||||
|
@ -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 ()
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user