Commit 29dc26a3 authored by Julien Lopez's avatar Julien Lopez
Browse files

[TESTS][LAMBDA] Fix tests (except map_even_hard failing the match of an abstr)

parent c833c519
......@@ -72,7 +72,8 @@ let tests_poly_abstr = [
*)
"Test CDuce.lambda.identity_applied failed",
"Apply(Abstraction(Dummy,Dummy,,,,Sel(Env(1),(`$A -> `$A),{ { `$A = Int
"Apply(PolyAbstraction(Dummy,Dummy,,,,Sel(Env(1),(`$A -> `$A),{ { `$A =
Int
} }),Env(1)),Const(2))",
"(fun f x : 'A : 'A -> x)[{A/Int}].2";
];;
......@@ -118,12 +119,11 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
in (let x : Int = f.2
in f.x : Int) : Int");
assert_equal ~msg:"Test CDuce.runtime.abstr.simple failed"
~printer:(fun x -> x) "Abstraction((Int,Int),Sel(1,(Int -> Int),Id))"
~printer:(fun x -> x) "Abstraction((Int,Int),Id)"
(run_test_eval "fun f x : Int : Int -> 2");
assert_equal ~msg:"Test CDuce.runtime.abstr.medium failed"
~printer:(fun x -> x)
"Abstraction((Int,[ Char* ] -> [ Int Char* ]),Sel(1,(Int -> [ Char* ] ->
[ Int Char* ]),Id))"
"Abstraction((Int,[ Char* ] -> [ Int Char* ]),Id)"
(run_test_eval "fun f x : Int y : String : (Int*String) -> x,y");
);
......@@ -142,8 +142,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
"misc" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.misc.even failed"
~printer:(fun x -> x)
"Abstraction((Int,Bool),(Any \\ (Int),Any \\ (Int)),Sel(1,(Int -> Bool),(
Any \\ (Int) -> Any \\ (Int)),Id))"
"Abstraction((Int,Bool),(Any \\ (Int),Any \\ (Int)),Id)"
(run_test_eval "fun ((Int -> Bool) & ((!Int) -> (!Int)))
| x : Int -> (match (x % 2) : Int with
| 0 -> `true
......@@ -175,8 +174,7 @@ Any \\ (Int) -> Any \\ (Int)),Id))"
| 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 \\ (Int | Bool),Any \\ (Int | Bool)),Sel(1,(
Int -> Bool),(Bool -> Bool),(Any \\ (Int | Bool) -> Any \\ (Int | Bool)),Id))"
"Abstraction((Int,Bool),(Bool,Bool),(Any \\ (Int | Bool),Any \\ (Int | Bool)),Id)"
(run_test_eval "fun ((Int -> Bool) & (Bool -> Bool) & ((!(Int|Bool)) -> (!(Int|Bool))))
| x : Int -> `true
| x : Bool -> `false
......@@ -204,9 +202,7 @@ Int -> Bool),(Bool -> Bool),(Any \\ (Int | Bool) -> Any \\ (Int | Bool)),Id))"
| x : (!(Int|Bool)) -> x).[2; 3]");
assert_equal ~msg:"Test CDuce.runtime.misc.map failed"
~printer:(fun x -> x)
"Abstraction((`$A -> `$B,[ `$A* ] -> [ `$B* ]),Sel(1,(`$A -> `$B -> [ `$A* ] ->
[
`$B* ]),Id))"
"Abstraction((`$A -> `$B,[ `$A* ] -> [ `$B* ]),Id)"
(run_test_eval "fun map f : ('A -> 'B) x : ['A] : ['B] ->
match x : ['A] with
| (el : 'A) :: [] -> f.el
......@@ -268,8 +264,7 @@ Bool } },Sel(1,(`$C -> `$C),Id))),(Atom(false),Atom(nil),Id),Id),Id),Id),Id),Id)
| x : (!(Int|Bool)) -> x).[`true; 3; `true]");
assert_equal ~msg:"Test CDuce.runtime.misc.firsts failed"
~printer:(fun x -> x)
"Abstraction(((Int,Int),X1 -> X1 where X1 = (Int,Int)),Sel(1,((Int,Int) ->
X1 -> X1 where X1 = (Int,Int)),Id))"
"Abstraction(((Int,Int),X1 -> X1 where X1 = (Int,Int)),Id)"
(run_test_eval "fun firsts x : (Int*Int) y : (Int*Int) : (Int*Int) ->
match x,y : ((Int*Int)*(Int*Int)) with
| (a : Int,_ : Int),(b : Int,_ : Int) -> a,b");
......@@ -280,7 +275,7 @@ X1 -> X1 where X1 = (Int,Int)),Id))"
| (a : Int,_ : Int),(b : Int,_ : Int) -> a,b)
.(5, 3)).(1, 4)");
assert_equal ~msg:"Test CDuce.runtime.misc.applier failed"
~printer:(fun x -> x) "Abstraction((Int,Int -> Int -> Int),Sel(1,(Int -> Int -> Int -> Int),Id))"
~printer:(fun x -> x) "Abstraction((Int,Int -> Int -> Int),Id)"
(run_test_eval "fun applier x : Int f : (Int->Int) : Int -> f.x");
assert_equal ~msg:"Test CDuce.runtime.misc.applier_applied failed"
~printer:(fun x -> x) "2"
......@@ -337,7 +332,7 @@ X1 -> X1 where X1 = (Int,Int)),Id))"
| (el : Int) :: (_ : [Int]) -> el
| [] -> 3");
assert_equal ~msg:"Test CDuce.runtime.list.tail failed"
~printer:(fun x -> x) "Abstraction(([ Int* ],[ Int* ]),Sel(1,([ Int* ] -> [ Int* ]),Id))"
~printer:(fun x -> x) "Abstraction(([ Int* ],[ Int* ]),Id)"
(run_test_eval "fun tail x : [Int] : [Int] -> match x : [Int] with
| (_ : Int) :: (rest : [Int]) -> rest");
assert_equal ~msg:"Test CDuce.runtime.list.tail.eval failed"
......@@ -390,12 +385,10 @@ X1 -> X1 where X1 = (Int,Int)),Id))"
"union" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.union.identity failed"
~printer:(fun x -> x) "Abstraction(([ Char* ] | Int,[ Char* ] | Int),Sel(1,([ Char* ] | Int ->
[ Char* ] | Int),Id))"
~printer:(fun x -> x) "Abstraction(([ Char* ] | Int,[ Char* ] | Int),Id)"
(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(([ Char* ] | Int,[ Char* ] | Int),Sel(1,([ Char* ] | Int ->
[ Char* ] | Int),Id))"
~printer:(fun x -> x) "Abstraction(([ Char* ] | Int,[ Char* ] | Int),Id)"
(run_test_eval "fun f x : (Int | String) : (Int | String) ->
match x : (Int | String) with
| _ : Int -> 2
......@@ -416,13 +409,11 @@ X1 -> X1 where X1 = (Int,Int)),Id))"
"union_precise" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.union_precise.identity failed"
~printer:(fun x -> x) "Abstraction((Int,Int),([ Char* ],[ Char* ]),Sel(1,(Int -> Int),([ Char* ] ->
[ Char* ]),Id))"
~printer:(fun x -> x) "Abstraction((Int,Int),([ Char* ],[ Char* ]),Id)"
(run_test_eval "fun ((Int -> Int) & (String -> String))
| x : (Int | String) -> x");
assert_equal ~msg:"Test CDuce.runtime.union_precise.match failed"
~printer:(fun x -> x) "Abstraction((Int,Int),([ Char* ],[ Char* ]),Sel(1,(Int -> Int),([ Char* ] ->
[ Char* ]),Id))"
~printer:(fun x -> x) "Abstraction((Int,Int),([ Char* ],[ Char* ]),Id)"
(run_test_eval "fun ((Int -> Int) & (String -> String))
| x : Int -> 2
| x : String -> \"Piece of cake\"");
......@@ -441,7 +432,7 @@ X1 -> X1 where X1 = (Int,Int)),Id))"
"poly" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.poly.identity_pure failed"
~printer:(fun x -> x)
"Abstraction((`$A,`$A),Sel(1,(`$A -> `$A),Id))"
"Abstraction((`$A,`$A),Id)"
(run_test_eval "fun f x : 'A : 'A -> x");
assert_equal ~msg:"Test CDuce.runtime.poly.identity failed"
~printer:(fun x -> x)
......@@ -456,7 +447,7 @@ X1 -> X1 where X1 = (Int,Int)),Id))"
(run_test_eval "((fun f x : 'A : 'A -> x)[{A/Int}]).2");
assert_equal ~msg:"Test CDuce.runtime.poly.tail failed"
~printer:(fun x -> x)
"Abstraction(([ `$A* ],[ `$A* ]),Sel(1,([ `$A* ] -> [ `$A* ]),Id))"
"Abstraction(([ `$A* ],[ `$A* ]),Id)"
(run_test_eval "fun tail x : ['A] : ['A] -> match x : ['A] with
| (_ : 'A) :: (rest : ['A]) -> rest");
assert_equal ~msg:"Test CDuce.runtime.poly.tail_applied failed"
......
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