Commit 33a1a15d authored by Julien Lopez's avatar Julien Lopez

Fix tests and git hook

parent a348bcd9
......@@ -72,9 +72,9 @@ let tests_poly_abstr = [
*)
"Test CDuce.lambda.identity_applied failed",
"Apply(PolyAbstraction(Dummy,Dummy,,{accept_chars=true; brs_disp=<disp>; brs_rhs=[| (1, Var(Local(0))) |]; brs_stack_pos=0},,Sel(Env(1),[(
"Apply(PolyAbstraction([Dummy,Dummy],,{accept_chars=true; brs_disp=<disp>; brs_rhs=[| (1, Var(Local(0))) |]; brs_stack_pos=0},,Sel(Env(1),[(
`$A -> `$A)],{{`$A = Int
}})),Const(2))",
}})),Const(2))",
"(fun f x : 'A : 'A -> x)[{A/Int}].2";
];;
......@@ -126,15 +126,15 @@ 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),Mono)"
~printer:(fun x -> x) "Abstraction([(Int,Int)],Mono)"
(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* ]),Mono)"
"Abstraction([(Int,[ Char* ] -> [ Int Char* ])],Mono)"
(run_test_eval "fun f x : Int y : String : (Int*String) -> x,y");
assert_equal ~msg:"Test CDuce.runtime.abstr.hard failed"
~printer:(fun x -> x)
"Abstraction((Int -> Int -> Int,Int -> Int -> Int),Mono)"
"Abstraction([(Int -> Int -> Int,Int -> Int -> Int)],Mono)"
(run_test_eval "fun (((Int -> Int) -> Int) -> (Int -> Int) -> Int) | x : ((Int -> Int) -> Int) -> (fun ((Int -> Int) -> Int) | y : (Int -> Int) -> x.y)");
);
......@@ -153,7 +153,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)),Mono)"
"Abstraction([(Int,Bool),(Any \\ (Int),Any \\ (Int))],Mono)"
(run_test_eval "fun ((Int -> Bool) & ((!Int) -> (!Int)))
| x : Int -> (match (x % 2) : Int with
| 0 -> `true
......@@ -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 \\ (Int | Bool),Any \\ (Int | Bool)),Mono)"
"Abstraction([(Int,Bool),(Bool,Bool),(Any \\ (Int | Bool),Any \\ (Int | Bool))],Mono)"
(run_test_eval "fun ((Int -> Bool) & (Bool -> Bool) & ((!(Int|Bool)) -> (!(Int|Bool))))
| x : Int -> `true
| x : Bool -> `false
......@@ -213,14 +213,14 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| x : (!(Int|Bool)) -> x).[2; 3]");
assert_equal ~msg:"Test CDuce.runtime.misc.map failed"
~printer:(fun x -> x)
"Abstraction((`$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
| (el : 'A) :: (rest : ['A]) -> ((f.el), ((map.f).rest))");
assert_equal ~msg:"Test CDuce.runtime.misc.map_even failed"
~printer:(fun x -> x)
"Abstraction(([ `$A* ],[ `$B* ]),Id)"
"Abstraction([([ `$A* ],[ `$B* ])],Id)"
(run_test_eval "(fun map f : ('A->'B) x : ['A] : ['B] ->
match x : ['A] with
| (el : 'A) :: (rest : ['A]) -> ((f.el), ((map.f).rest))
......@@ -253,8 +253,8 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| x : (!Int) -> x).[4; \"hey\"; 3; 2]");
assert_equal ~msg:"Test CDuce.runtime.misc.map_even_hard failed"
~printer:(fun x -> x)
"(Atom(true),(\"hey\",((3,(5,Atom(nil),Mono),Mono),(Atom(true),(Abstraction((
`$C,`$C),Mono),(Atom(false),Atom(nil),Mono),Mono),Mono),Mono),Mono),Mono)"
"(Atom(true),(\"hey\",((3,(5,Atom(nil),Mono),Mono),(Atom(true),(Abstraction([(
`$C,`$C)],Id),(Atom(false),Atom(nil),Mono),Mono),Mono),Mono),Mono),Mono)"
(run_test_eval "(fun map f : ('A->'B) x : ['A] : ['B] ->
match x : ['A] with
| (el : 'A) :: (rest : ['A]) -> ((f.el), ((map.f).rest))
......@@ -285,7 +285,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| 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)),Mono)"
"Abstraction([((Int,Int),X1 -> X1 where X1 = (Int,Int))],Mono)"
(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");
......@@ -296,7 +296,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| (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),Mono)"
~printer:(fun x -> x) "Abstraction([(Int,Int -> Int -> Int)],Mono)"
(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"
......@@ -356,7 +356,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| (el : Int) :: (_ : [Int]) -> el
| [] -> 3");
assert_equal ~msg:"Test CDuce.runtime.list.tail failed"
~printer:(fun x -> x) "Abstraction(([ Int* ],[ Int* ]),Mono)"
~printer:(fun x -> x) "Abstraction([([ Int* ],[ Int* ])],Mono)"
(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"
......@@ -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(([ Char* ] | Int,[ Char* ] | Int),Mono)"
~printer:(fun x -> x) "Abstraction([([ Char* ] | Int,[ Char* ] | Int)],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(([ Char* ] | Int,[ Char* ] | Int),Mono)"
~printer:(fun x -> x) "Abstraction([([ Char* ] | Int,[ Char* ] | Int)],Mono)"
(run_test_eval "fun f x : (Int | String) : (Int | String) ->
match x : (Int | String) with
| _ : Int -> 2
......@@ -433,11 +433,11 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
"union_precise" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.union_precise.identity failed"
~printer:(fun x -> x) "Abstraction((Int,Int),([ Char* ],[ Char* ]),Mono)"
~printer:(fun x -> x) "Abstraction([(Int,Int),([ Char* ],[ Char* ])],Mono)"
(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* ]),Mono)"
~printer:(fun x -> x) "Abstraction([(Int,Int),([ Char* ],[ Char* ])],Mono)"
(run_test_eval "fun ((Int -> Int) & (String -> String))
| x : Int -> 2
| x : String -> \"Piece of cake\"");
......@@ -456,13 +456,13 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
"poly" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.poly.identity_pure failed"
~printer:(fun x -> x)
"Abstraction((`$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)
"Abstraction((`$A,`$A),Sel(1,[(`$A -> `$A)],{{ `$A = Int },{ `$A = [ Char* ]
}}))"
"Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],{{`$A = Int},{`$A = [ Char* ]
}}))"
(run_test_eval "(fun f x : 'A : 'A -> x)[{A/Int},{A/String}]");
assert_equal ~msg:"Test CDuce.runtime.poly.identity_applied failed"
......@@ -475,7 +475,7 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
assert_equal ~msg:"Test CDuce.runtime.poly.tail failed"
~printer:(fun x -> x)
"Abstraction(([ `$A* ],[ `$A* ]),Id)"
"Abstraction([([ `$A* ],[ `$A* ])],Id)"
(run_test_eval "fun tail x : ['A] : ['A] -> match x : ['A] with
| (_ : 'A) :: (rest : ['A]) -> rest");
......@@ -485,32 +485,32 @@ let tests_eval = "CDuce runtime tests (Typed -> Lambda -> Value)" >:::
| (_ : 'A) :: (rest : ['A]) -> rest).[3; 7; 8; 5]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp failed"
~printer:(fun x -> x) "Abstraction((`$A,`$A),Sel(1,[(`$A -> `$A)],{{ `$A = Int
}}))"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],{{`$A = Int
}}))"
(run_test_eval "(((fun f x : 'A : 'A -> x)[{A/Int}])[{A/String}])[{A/Bool}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.2 failed"
~printer:(fun x -> x) "Abstraction((`$A,`$A),Sel(1,[(`$A -> `$A)],Comp(Comp({{ `$A = `$B
}},{{ `$B = `$A }}),{{ `$A = `$B
}})))"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp(Comp({{`$A = `$B
}},{{`$B = `$A}}),{{`$A = `$B
}})))"
(run_test_eval "(((fun f x : 'A : 'A -> x)[{A/'B}])[{B/'A}])[{A/'B}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.3 failed"
~printer:(fun x -> x) "Abstraction((`$A,`$A),Sel(1,[(`$A -> `$A)],Comp(Comp(Comp({{ `$B = `$A
}},{{ `$A = `$B }}),{{ `$B = `$A }}),{{ `$A = `$B
}})))"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp(Comp(Comp({{`$B = `$A
}},{{`$A = `$B}}),{{`$B = `$A}}),{{`$A = `$B
}})))"
(run_test_eval "((((fun f x : 'A : 'A -> x)[{A/'B}])[{B/'A}])[{A/'B}])[{B/'A}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.4 failed"
~printer:(fun x -> x) "Abstraction((`$A,`$A),Sel(1,[(`$A -> `$A)],Comp({{ `$B = Int }},{{ `$A =
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp({{`$B = Int}},{{`$A =
`$B
}})))"
}})))"
(run_test_eval "(((((fun f x : 'A : 'A -> x)[{A/'B}])[{A/Int}])[{B/Int}])[{B/Int}])[{B/'A}]");
assert_equal ~msg:"Test CDuce.runtime.poly.multicomp.5 failed"
~printer:(fun x -> x) "Abstraction((`$A,`$A),Sel(1,[(`$A -> `$A)],Comp(Comp({{ `$D = `$C
},{ `$C = `$B }},{{ `$B = `$C } }),{{ `$A = `$B } ,{ `$C = `$D
}})))"
~printer:(fun x -> x) "Abstraction([(`$A,`$A)],Sel(1,[(`$A -> `$A)],Comp(Comp({{`$D = `$C
},{`$C = `$B}},{{`$B = `$C}}),{{`$A = `$B},{`$C = `$D
}})))"
(run_test_eval "((((fun f x : 'A : 'A -> x)[{A/'B},{C/'D}])[{B/'C}])[{B/'D}])[{D/'C},{C/'B}]");
);
......
......@@ -57,7 +57,7 @@ let test_print =
(Printf.sprintf " Printing %s " s) >:: (fun _ ->
let t = parse_typ s in
Format.printf "String : %s\n" s;
Format.printf "Print : %a\n\n" Types.Print.print t;
Format.printf "Print : %a\n\n" Types.Print.pp_value t;
(*
Format.printf "Dump : %a\n\n" Types.dump t;
*)
......
......@@ -42,6 +42,6 @@ let rex =
;;
let string = Sequence.star Types.Char.any ;;
Types.Print.print Format.std_formatter rex;
Types.Print.pp_value Format.std_formatter rex;
Format.fprintf Format.std_formatter "\n"
......@@ -16,6 +16,10 @@ fi
echo "Testing lambda..."
cd tests/lambda
make > /dev/null 2>&1 && ./lambdaTests.native > /dev/null 2>&1 && ./valueTests.native > /dev/null 2>&1
if test $? -ne 0; then
echo "Tests failed. Aborting commit."
exit 2
fi
echo "Cleaning..."
make clean > /dev/null 2>&1
cd ../..
......
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