Commit d2de4b28 authored by Pietro Abate's avatar Pietro Abate
Browse files

Add sigma -> Fix test cases

parent 5c6f05c3
......@@ -21,10 +21,10 @@ let tests = "CDuce runtime tests" >:::
[
"abstr" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.abstr.simple failed"
~printer:(fun x -> x) "Abstraction((Int, Int))"
~printer:(fun x -> x) "Abstraction((Int, Int),{})"
(run_test "fun f x : Int : Int -> 2");
assert_equal ~msg:"Test CDuce.runtime.abstr.medium failed"
~printer:(fun x -> x) "Abstraction((Int, [ Char* ] -> [ Int Char* ]))"
~printer:(fun x -> x) "Abstraction((Int, [ Char* ] -> [ Int Char* ]),{})"
(run_test "fun f x : Int y : String : (Int*String) -> x,y");
);
......@@ -33,27 +33,27 @@ let tests = "CDuce runtime tests" >:::
~printer:(fun x -> x) "2"
(run_test "(fun f x : Int : Int -> x).2");
assert_equal ~msg:"Test CDuce.runtime.apply.simple_pair failed"
~printer:(fun x -> x) "(3, 2)"
~printer:(fun x -> x) "(3, 2, {})"
(run_test "(fun f x : (Int*Int) : (Int*Int) -> x).(3,2)");
assert_equal ~msg:"Test CDuce.runtime.apply.medium failed"
~printer:(fun x -> x) "(2, 3)"
~printer:(fun x -> x) "(2, 3, {})"
(run_test "((fun f x : Int y : Int : (Int*Int) -> x,y).2).3");
);
"misc" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.misc.firsts failed"
~printer:(fun x -> x) "Abstraction(((Int,Int), (Int,Int) -> (Int,Int)))"
~printer:(fun x -> x) "Abstraction(((Int,Int), (Int,Int) -> (Int,Int)),{})"
(run_test "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");
assert_equal ~msg:"Test CDuce.runtime.misc.firsts_applied failed"
~printer:(fun x -> x) "(5, 1)"
~printer:(fun x -> x) "(5, 1, {})"
(run_test "((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)
.(5, 3)).(1, 4)");
assert_equal ~msg:"Test CDuce.runtime.misc.applier failed"
~printer:(fun x -> x) "Abstraction((Int, Int -> Int -> Int))"
~printer:(fun x -> x) "Abstraction((Int, Int -> Int -> Int),{})"
(run_test "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"
......@@ -101,11 +101,11 @@ let tests = "CDuce runtime tests" >:::
| (el : Int) :: (rest : [Int]) -> el
| x : Int -> 3");
assert_equal ~msg:"Test CDuce.runtime.list.tail failed"
~printer:(fun x -> x) "Abstraction(([ Int* ], [ Int* ]))"
~printer:(fun x -> x) "Abstraction(([ Int* ], [ Int* ]),{})"
(run_test "fun tail x : [Int] : [Int] -> match x : [Int] with
| (el : Int) :: (rest : [Int]) -> rest");
assert_equal ~msg:"Test CDuce.runtime.list.tail.eval failed"
~printer:(fun x -> x) "(2, 5)"
~printer:(fun x -> x) "(2, 5, {})"
(run_test "(fun tail x : [Int] : [Int] -> match x : [Int] with
| (el : Int) :: (rest : [Int]) -> rest).[1; 2; 5]");
(* TODO: Fix this test, we need to define [] aka `nil *)
......@@ -118,10 +118,10 @@ let tests = "CDuce runtime tests" >:::
"union" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.union.identity failed"
~printer:(fun x -> x) "Abstraction(([ Char* ] | Int, [ Char* ] | Int))"
~printer:(fun x -> x) "Abstraction(([ Char* ] | Int, [ Char* ] | Int),{})"
(run_test "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))"
~printer:(fun x -> x) "Abstraction(([ Char* ] | Int, [ Char* ] | Int),{})"
(run_test "fun f x : (Int | String) : (Int | String) ->
match x : (Int | String) with
| x : Int -> 2
......@@ -144,11 +144,11 @@ let tests = "CDuce runtime tests" >:::
assert_equal ~msg:"Test CDuce.runtime.poly.identity_pure failed"
~printer:(fun x -> x)
"Abstraction((`$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | \
Arrow, `$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | Arrow))"
Arrow, `$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | Arrow),{})"
(run_test "fun f x : 'A{} : 'A{} -> x");
assert_equal ~msg:"Test CDuce.runtime.poly.identity failed"
~printer:(fun x -> x)
"Abstraction(([ Char* ] | Int, [ Char* ] | Int))"
"Abstraction(([ Char* ] | Int, [ Char* ] | Int),{})"
(run_test "(fun f x : 'A{A/Int;A/String} : 'A{A/Int;A/String} -> x)
{A/Int;A/String}");
assert_equal ~msg:"Test CDuce.runtime.poly.identity_applied failed"
......@@ -163,11 +163,11 @@ Arrow, `$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | Arrow))"
~printer:(fun x -> x)
"Abstraction(([ (`$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any \
| Arrow)* ], [ (`$A & Int | Char | Atom | (Any,Any) | <(Any) (Any)>Any | \
Arrow)* ]))"
Arrow)* ]),{})"
(run_test "fun tail x : ['A{}] : ['A{}] -> match x : ['A{}] with
| (el : 'A{}) :: (rest : ['A{}]) -> rest");
assert_equal ~msg:"Test CDuce.runtime.poly.tail_applied failed"
~printer:(fun x -> x) "(7, (8, 5))"
~printer:(fun x -> x) "(7, (8, 5, {}), {})"
(run_test "(fun tail x : ['A{}] : ['A{}] -> match x : ['A{}] with
| (el : 'A{}) :: (rest : ['A{}]) -> rest).[3; 7; 8; 5]");
);
......
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