Commit 17e63c21 authored by Julien Lopez's avatar Julien Lopez

Bugfix in parser: syntactic sugar if_then_else

parent f3ca4bed
......@@ -112,7 +112,9 @@ let is_capture =
)
let if_then_else cond e1 e2 = Match (cond, [pat_true,e1; pat_false,e2])
let if_then_else cond e1 e2 =
Match (cond, [(mk (0,0) (Cst (Atom (ident "true")))),e1;
(mk (0,0) (Cst (Atom (ident "false")))),e2])
let logical_and e1 e2 = if_then_else e1 e2 cst_false
let logical_or e1 e2 = if_then_else e1 cst_true e2
......
......@@ -185,7 +185,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| x : (!Int) -> x).[2; 3]");
assert_equal ~msg:"Test CDuce.runtime.misc.is_int failed"
~printer:(fun x -> x)
"Abstraction([(Int,Bool),(Bool,Bool),(Any \\ (Bool | Int),Any \\ (Bool | Int))],Mono)"
"Abstraction([(Int,Bool),(Bool,Bool),(Any \\ ((Bool | Int)),Any \\ ((Bool | Int)))],Mono)"
(run_test_eval "fun ((Int -> Bool) & (Bool -> Bool) & ((!(Int|Bool)) -> (!(Int|Bool))))
| x : Int -> `true
| x : Bool -> `false
......@@ -409,10 +409,10 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
"union" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.union.identity failed"
~printer:(fun x -> x) "Abstraction([(Int | [ Char* ],Int | [ Char* ])],Mono)"
~printer:(fun x -> x) "Abstraction([((Int | [ Char* ]),(Int | [ Char* ]))],Mono)"
(run_test_eval "fun f x : (Int | String) : (Int | String) -> x");
assert_equal ~msg:"Test CDuce.runtime.union.match failed"
~printer:(fun x -> x) "Abstraction([(Int | [ Char* ],Int | [ Char* ])],Mono)"
~printer:(fun x -> x) "Abstraction([((Int | [ Char* ]),(Int | [ Char* ]))],Mono)"
(run_test_eval "fun f x : (Int | String) : (Int | String) ->
match x : (Int | String) with
| _ : Int -> 2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment