diff --git a/src/bin/expect_tests/failwith_tests.ml b/src/bin/expect_tests/failwith_tests.ml new file mode 100644 index 000000000..d957f03c0 --- /dev/null +++ b/src/bin/expect_tests/failwith_tests.ml @@ -0,0 +1,36 @@ +open Cli_expect + +let contract basename = + "../../test/contracts/" ^ basename +let bad_contract basename = + "../../test/contracts/negative/" ^ basename + +let%expect_test _ = + run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ] ; + [%expect {| + failwith("some_string") |}]; + + run_ligo_good [ "run-function" ; contract "failwith.ligo" ; "failer" ; "1" ; "--format=json" ] ; + [%expect {| + {"status":"ok","content":"failwith(\"some_string\")"} |}]; + + + run_ligo_good [ "dry-run" ; contract "subtle_nontail_fail.mligo" ; "main" ; "()" ; "()" ] ; + [%expect {| + failwith("This contract always fails") |}]; + + run_ligo_good [ "interpret" ; "assert(1=1)" ; "--syntax=pascaligo" ] ; + [%expect {| + Unit |}]; + + run_ligo_good [ "interpret" ; "assert(1=2)" ; "--syntax=pascaligo" ] ; + [%expect {| + failwith("failed assertion") |}]; + + run_ligo_good [ "interpret" ; "assert(1=1)" ; "--syntax=cameligo" ] ; + [%expect {| + Unit |}]; + + run_ligo_good [ "interpret" ; "assert(1=2)" ; "--syntax=cameligo" ] ; + [%expect {| + failwith("failed assertion") |}]; diff --git a/src/passes/operators/operators.ml b/src/passes/operators/operators.ml index 142c3d087..be1196ad1 100644 --- a/src/passes/operators/operators.ml +++ b/src/passes/operators/operators.ml @@ -66,7 +66,7 @@ module Simplify = struct module Pascaligo = struct let constants = function - | "get_force" -> ok C_MAP_FIND + | "assert" -> ok C_ASSERTION | "get_chain_id" -> ok C_CHAIN_ID | "transaction" -> ok C_CALL | "get_contract" -> ok C_CONTRACT @@ -106,6 +106,7 @@ module Simplify = struct | "list_iter" -> ok C_LIST_ITER | "list_fold" -> ok C_LIST_FOLD | "list_map" -> ok C_LIST_MAP + | "get_force" -> ok C_MAP_FIND | "map_iter" -> ok C_MAP_ITER | "map_map" -> ok C_MAP_MAP | "map_fold" -> ok C_MAP_FOLD