Commit 54fb8ae2 authored by Julien Lopez's avatar Julien Lopez
Browse files

[TESTS][LAMBDA] apply has now a highest priority than pair; add two tests

parent 835a6a6c
......@@ -337,6 +337,19 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
(run_test_eval "(fun concat x : [[Int]] : [Int] -> match x : [[Int]] with
| (el : [Int]) :: [] -> el
| (el : [Int]) :: (rest : [[Int]]) -> (el@(concat.rest))).[[1; 2; 5; 4; 8; 7]; [2; 3; 4]]");
assert_equal ~msg:"Test CDuce.runtime.list.length_easy failed"
~printer:(fun x -> x) "6"
(run_test_eval "(fun length x : [Int] : Int -> match x : [Int] with
| [] -> 0
| (el : Int) :: (rest : [Int]) -> length.rest + 1).[1; 2; 5; 4; 8; 7]");
assert_equal ~msg:"Test CDuce.runtime.list.length_hard failed"
~printer:(fun x -> x) "((6, 0, {}), 2, {})"
(run_test_eval "let length : (['A{A/Int; A/Bool}] -> Int) =
(fun f l : ['A{A/Int; A/Bool}] : Int -> match l : ['A{A/Int; A/Bool}] with
| [] -> 0
| (el : 'A{A/Int; A/Bool}) :: (rest : ['A{A/Int; A/Bool}]) -> f.rest + 1)
in
(length.[1; 2; 5; 4; 8; 7], length.[], length.[`true; 2]) : (Int*Int*Int)");
);
"union" >:: ( fun test_ctxt ->
......
......@@ -71,9 +71,8 @@ module ExprParser = struct
| e1 = SELF; "/"; e2 = SELF -> Op(_loc, "/", e1, e2)
| e1 = SELF; "%"; e2 = SELF -> Op(_loc, "%", e1, e2) ]
| "concat" LEFTA [ e1 = SELF; "@"; e2 = SELF -> Op(_loc, "@", e1, e2) ]
| "pair" LEFTA
[ e1 = SELF; ","; e2 = SELF -> Pair(_loc, e1, e2)
| e1 = SELF ; "."; e2 = SELF -> Apply(_loc, e1, e2) ]
| "pair" LEFTA [ e1 = SELF; ","; e2 = SELF -> Pair(_loc, e1, e2) ]
| "apply" [ e1 = SELF ; "."; e2 = SELF -> Apply(_loc, e1, e2) ]
| "list" LEFTA
[ "["; le = LIST0 SELF SEP ";"; "]" ->
let rec make_seq res = function
......
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