Added failwith to camligo

This commit is contained in:
Georges Dupéron 2019-06-05 19:19:44 +02:00
parent da4e3e5b80
commit 02785aa754
2 changed files with 15 additions and 0 deletions

View File

@ -62,6 +62,7 @@ module Simplify = struct
("amount" , "AMOUNT") ;
("unit" , "UNIT") ;
("source" , "SOURCE") ;
("failwith" , "FAILWITH") ;
]
let type_constants = type_constants
@ -149,6 +150,12 @@ module Typer = struct
(is_t_map t || is_t_list t) in
ok @@ t_nat ()
let failwith_ = typer_1 "FAILWITH" @@ fun t ->
let%bind () =
Assert.assert_true @@
(is_t_string t) in
ok @@ t_unit ()
let get_force = typer_2 "MAP_GET_FORCE" @@ fun i m ->
let%bind (src, dst) = get_t_map m in
let%bind _ = assert_type_value_eq (src, i) in
@ -246,6 +253,7 @@ module Typer = struct
map_update ;
int ;
size ;
failwith_ ;
get_force ;
bytes_pack ;
bytes_unpack ;

View File

@ -450,6 +450,12 @@ let counter_mligo () : unit result =
let make_expected = fun n -> e_pair (e_typed_list [] t_operation) (e_int (42 + n)) in
expect_eq_n program "main" make_input make_expected
let failwith_mligo () : unit result =
let%bind program = mtype_file "./contracts/failwith.mligo" in
let make_input = e_pair (e_unit ()) (e_unit ()) in
let make_expected = e_pair (e_typed_list [] t_operation) (e_unit ()) in
expect_eq program "main" make_input make_expected
let guess_the_hash_mligo () : unit result =
let%bind program = mtype_file "./contracts/new-syntax.mligo" in
let make_input = fun n-> e_pair (e_int n) (e_int 42) in
@ -493,4 +499,5 @@ let main = test_suite "Integration (End to End)" [
test "basic mligo" basic_mligo ;
test "counter contract mligo" counter_mligo ;
(* test "guess the hash mligo" guess_the_hash_mligo ; *)
(* test "failwith mligo" failwith_mligo ; *)
]