Commit a26c2fe2 authored by Julien Lopez's avatar Julien Lopez
Browse files

[TESTS][LAMBDA] Add let expressions

parent 39503fcb
......@@ -4,6 +4,7 @@ expr = id
| `false
| string
| abstr
| "let" string ":" type_id "=" expr "in" expr ":" type_id
| expr "." expr
| expr "," expr
| expr "+" expr
......
......@@ -74,6 +74,9 @@ let run_test_eval str =
let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
[
"abstr" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.abstr.let_simple failed"
~printer:(fun x -> x) "3"
(run_test_eval "let x : Int = 3 in x : Int");
assert_equal ~msg:"Test CDuce.runtime.abstr.simple failed"
~printer:(fun x -> x) "Abstraction((Int, Int),{})"
(run_test_eval "fun f x : Int : Int -> 2");
......
......@@ -59,6 +59,9 @@ module ExprParser = struct
in
aux e t (make_fv [] 1 p) (List.rev p)
| "fun"; t = type_id; b = LIST1 branch -> Abstr(_loc, "_", t, [], b)
| "let"; x = LIDENT; ":"; t = type_id; "="; v = SELF; "in"; e = SELF;
":"; te = type_id -> Apply(_loc, Abstr(_loc, "_", TArrow(t, te), [],
[_loc, MVar(_loc, x, t), e]), v)
| "match"; e = SELF; ":"; t = type_id; "with"; b = LIST1 branch ->
Match(_loc, e, t, b) ]
| "add" LEFTA
......
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