add assert primitive for pascaligo
This commit is contained in:
parent
54f4ffd413
commit
5ef61d3520
36
src/bin/expect_tests/failwith_tests.ml
Normal file
36
src/bin/expect_tests/failwith_tests.ml
Normal file
@ -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") |}];
|
@ -66,7 +66,7 @@ module Simplify = struct
|
|||||||
module Pascaligo = struct
|
module Pascaligo = struct
|
||||||
|
|
||||||
let constants = function
|
let constants = function
|
||||||
| "get_force" -> ok C_MAP_FIND
|
| "assert" -> ok C_ASSERTION
|
||||||
| "get_chain_id" -> ok C_CHAIN_ID
|
| "get_chain_id" -> ok C_CHAIN_ID
|
||||||
| "transaction" -> ok C_CALL
|
| "transaction" -> ok C_CALL
|
||||||
| "get_contract" -> ok C_CONTRACT
|
| "get_contract" -> ok C_CONTRACT
|
||||||
@ -106,6 +106,7 @@ module Simplify = struct
|
|||||||
| "list_iter" -> ok C_LIST_ITER
|
| "list_iter" -> ok C_LIST_ITER
|
||||||
| "list_fold" -> ok C_LIST_FOLD
|
| "list_fold" -> ok C_LIST_FOLD
|
||||||
| "list_map" -> ok C_LIST_MAP
|
| "list_map" -> ok C_LIST_MAP
|
||||||
|
| "get_force" -> ok C_MAP_FIND
|
||||||
| "map_iter" -> ok C_MAP_ITER
|
| "map_iter" -> ok C_MAP_ITER
|
||||||
| "map_map" -> ok C_MAP_MAP
|
| "map_map" -> ok C_MAP_MAP
|
||||||
| "map_fold" -> ok C_MAP_FOLD
|
| "map_fold" -> ok C_MAP_FOLD
|
||||||
|
Loading…
Reference in New Issue
Block a user