diff --git a/src/test/contracts/failwith.ligo b/src/test/contracts/failwith.ligo index 9a59c5ec4..5b1f6b6af 100644 --- a/src/test/contracts/failwith.ligo +++ b/src/test/contracts/failwith.ligo @@ -10,3 +10,21 @@ function main (const p : param; const s : unit) : list(operation) * unit is end } with ((nil : list(operation)), s) + +function foobar (const i : int) : unit is + var p : param := Zero (42n) ; + block { + if i > 0 then block { + i := i + 1 ; + if i > 10 then block { + i := 20 ; + failwith ("who knows") ; + i := 30 ; + } else skip + } else block { + case p of + | Zero (n) -> failwith ("wooo") + | Pos (n) -> skip + end + } + } with unit diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 10d671050..9c055964e 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -651,6 +651,11 @@ let failwith_ligo () : unit result = let%bind _ = should_fail (e_pair (e_constructor "Zero" (e_nat 1)) (e_unit ())) in let%bind _ = should_work (e_pair (e_constructor "Pos" (e_nat 1)) (e_unit ())) in let%bind _ = should_fail (e_pair (e_constructor "Pos" (e_nat 0)) (e_unit ())) in + let should_fail input = expect_fail program "foobar" (e_int input) in + let should_work input = expect_eq program "foobar" (e_int input) (e_unit ()) in + let%bind () = should_fail @@ 10 in + let%bind () = should_fail @@ -10 in + let%bind () = should_work @@ 5 in ok () let failwith_mligo () : unit result =