WIP: add test. still have two ECond implementation, none of them pass the test
This commit is contained in:
parent
704c744ace
commit
b721a19b00
@ -379,28 +379,22 @@ let rec simpl_expression (t:Raw.expr) : expr result =
|
||||
| ELogic l -> simpl_logic_expression l
|
||||
| EList l -> simpl_list_expression l
|
||||
| ESet s -> simpl_set_expression s
|
||||
| ECond _ -> ( failwith "TODO"
|
||||
(*
|
||||
let (c , loc) = r_split c in
|
||||
| ECond c -> (*fail @@ simple_error "TODO"*)
|
||||
(* let (c , loc) = r_split c in
|
||||
let%bind expr = simpl_expression c.test in
|
||||
|
||||
let%bind match_true = simpl_expression c.ifso in
|
||||
let%bind match_false = simpl_expression c.ifnot in
|
||||
return @@ e_matching expr ~loc (Match_bool {match_true; match_false}) *)
|
||||
|
||||
let%bind match_true = match_true None in
|
||||
let%bind match_false = match_false None in
|
||||
return @@ e_matching expr ~loc (Match_bool {match_true; match_false})
|
||||
*)
|
||||
|
||||
(*
|
||||
let%bind lst =
|
||||
bind_list @@
|
||||
[ok (Raw.PTrue Region.ghost, simpl_expression c.ifso);
|
||||
ok (Raw.PFalse Region.ghost, simpl_expression c.ifnot)] in
|
||||
let (c , loc) = r_split c in
|
||||
let%bind expr = simpl_expression c.test in
|
||||
let%bind match_true = simpl_expression c.ifso in
|
||||
let%bind match_false = simpl_expression c.ifnot in
|
||||
let%bind lst = ok @@
|
||||
[(Raw.PTrue Region.ghost, match_true);
|
||||
(Raw.PFalse Region.ghost, match_false)] in
|
||||
let%bind cases = simpl_cases lst in
|
||||
return @@ e_matching ~loc e cases
|
||||
*)
|
||||
)
|
||||
return @@ e_matching ~loc expr cases
|
||||
| ECase c -> (
|
||||
let (c , loc) = r_split c in
|
||||
let%bind e = simpl_expression c.expr in
|
||||
|
@ -8,3 +8,9 @@ function main (const i : int) : int is
|
||||
else
|
||||
result := 0
|
||||
end with result
|
||||
|
||||
function foo (const b : bool) : int is
|
||||
var x : int := 41 ;
|
||||
begin
|
||||
x := 1 + (if b then x else main(x)) ;
|
||||
end with x
|
@ -587,9 +587,16 @@ let list () : unit result =
|
||||
|
||||
let condition () : unit result =
|
||||
let%bind program = type_file "./contracts/condition.ligo" in
|
||||
let make_input = e_int in
|
||||
let make_expected = fun n -> e_int (if n = 2 then 42 else 0) in
|
||||
expect_eq_n program "main" make_input make_expected
|
||||
let%bind _ =
|
||||
let make_input = e_int in
|
||||
let make_expected = fun n -> e_int (if n = 2 then 42 else 0) in
|
||||
expect_eq_n program "main" make_input make_expected
|
||||
in
|
||||
let%bind _ =
|
||||
let make_expected = fun b -> e_int (if b then 42 else 1) in
|
||||
expect_eq_b program "main" make_expected
|
||||
in
|
||||
ok ()
|
||||
|
||||
let condition_simple () : unit result =
|
||||
let%bind program = type_file "./contracts/condition-simple.ligo" in
|
||||
|
Loading…
Reference in New Issue
Block a user