From 02785aa75467e3a80aed03407224acf9686de001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Wed, 5 Jun 2019 19:19:44 +0200 Subject: [PATCH] Added failwith to camligo --- src/operators/operators.ml | 8 ++++++++ src/test/integration_tests.ml | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/src/operators/operators.ml b/src/operators/operators.ml index 6bec03b63..48fcd9a57 100644 --- a/src/operators/operators.ml +++ b/src/operators/operators.ml @@ -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 ; diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index e303ac29f..f3b8dfa58 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -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 ; *) ]