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

[TESTS][TYPED] Add reference from CDuce stable for non-polymorphic tests

parent 88631e30
open OUnit2
open Printer
let load_file f =
let ic = open_in f in
let n = in_channel_length ic in
let s = String.create n in
really_input ic s 0 n;
close_in ic;
s
let run_test str =
try
let st = Stream.of_string str in
......@@ -13,13 +21,13 @@ let tests = "CDuce runtime tests" >:::
[
"abstr" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.typed.abstr.identity failed"
~printer:(fun x -> x) ""
~printer:(fun x -> x) (load_file "tests/abstr/identity.ref")
(run_test "(fun (Int -> Int) | x -> x)2");
);
"misc" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.misc.firsts failed"
~printer:(fun x -> x) ""
~printer:(fun x -> x) (load_file "tests/misc/firsts.ref")
(run_test "(fun ((Int,Int) -> (Int,Int) -> (Int,Int))
| (x, _) -> (fun ((Int,Int) -> (Int,Int))
| (y, _) -> (x, y))) (2,3) (1,5)");
......@@ -27,23 +35,23 @@ let tests = "CDuce runtime tests" >:::
"match" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.match.medium failed"
~printer:(fun x -> x) ""
~printer:(fun x -> x) (load_file "tests/match/medium.ref")
(run_test "(fun (Int -> Int) | x ->
(match x with | 1 -> 3 | x -> x)) 2");
assert_equal ~msg:"Test CDuce.runtime.match.simple failed"
~printer:(fun x -> x) ""
~printer:(fun x -> x) (load_file "tests/match/simple.ref")
(run_test "(fun (Int -> Int) | x -> (match x with | _ -> x)) 2");
);
"list" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.list.tail failed"
~printer:(fun x -> x) ""
~printer:(fun x -> x) (load_file "tests/list/tail.ref")
(run_test "fun ([Int*] -> [Int*]) | [_ (rest::(Int*))] -> rest | [] -> []");
);
"union" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test CDuce.runtime.union.match failed"
~printer:(fun x -> x) ""
~printer:(fun x -> x) (load_file "tests/union/match.ref")
(run_test "fun (Int | String -> Int | String) | x ->
match x with
| _ & Int -> 2
......
{typ:Int; descr=({typ:Int -> Int; descr=Abstraction(name:<none>,
iface:[(Int, Int)],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Var(0, x)}}}], typ:Int -> Int, fv:[])}).({typ:Int; descr=Integer(2)})}
{typ:X1 -> X1 where X1 = [ Int* ]; descr=Abstraction(name:<none>,
iface:[([ Int* ], [ Int* ])],
body:[typ:[ Int* ], accept:[ (Any Int*)? ], branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[[ Any Int* ]; [(0, rest)]; Times({id:5; descr:[Any; []; Constr(Any)]; accept:[id:179; descr:Any]; fv:[]}, {id:4; descr:[[ Int* ]; [(0, rest)]; Cap([Any; [(0, rest)]; Capture(0, rest)], [[ Int* ]; []; Constr([ Int* ])])]; accept:[id:178; descr:[ Int* ]]; fv:[(0, rest)]})]; accept:[id:177; descr:[ Any Int* ]]; fv:[(0, rest)]};
body:{typ:[ Int* ], descr:{typ:[ Int* ]; descr=Var(0, rest)}}},
{used:true; ghost:false; br_vars_empty:[];
pat:{id:6; descr:[[ ]; []; Constr([ ])]; accept:[id:180; descr:[ ]]; fv:[]};
body:{typ:[ Int* ], descr:{typ:[ Int* ]; descr=Atom(nil)}}}], typ:X1 -> X1 where X1 = [ Int* ], fv:[])}
{typ:Int; descr=({typ:Int -> Int; descr=Abstraction(name:<none>,
iface:[(Int, Int)],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Match({typ:Int; descr=Var(0, x)},typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[1; []; Constr(1)]; accept:[id:177; descr:1]; fv:[]};
body:{typ:Int, descr:{typ:Int; descr=Integer(3)}}},
{used:true; ghost:false; br_vars_empty:[];
pat:{id:5; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:178; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Var(0, x)}}})}}}], typ:Int -> Int, fv:[])}).({typ:Int; descr=Integer(2)})}
{typ:Int; descr=({typ:Int -> Int; descr=Abstraction(name:<none>,
iface:[(Int, Int)],
body:[typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:Int, descr:{typ:Int; descr=Match({typ:Int; descr=Var(0, x)},typ:Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Any; []; Constr(Any)]; accept:[id:177; descr:Any]; fv:[]};
body:{typ:Int, descr:{typ:Int; descr=Var(0, x)}}})}}}], typ:Int -> Int, fv:[])}).({typ:Int; descr=Integer(2)})}
{typ:(Int,Int); descr=({typ:X1 -> X1 where X1 = (Int,Int); descr=({typ:X1 -> X1 -> X1 where X1 = (Int,Int); descr=Abstraction(name:<none>,
iface:[((Int,Int), X1 -> X1 where X1 = (Int,Int))],
body:[typ:(Int,Int), accept:Pair, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Pair; [(0, x)]; Times({id:5; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:180; descr:Any]; fv:[(0, x)]}, {id:4; descr:[Any; []; Constr(Any)]; accept:[id:179; descr:Any]; fv:[]})]; accept:[id:178; descr:Pair]; fv:[(0, x)]};
body:{typ:X1 -> X1 where X1 = (Int,Int), descr:{typ:X1 -> X1 where X1 = (Int,Int); descr=Abstraction(name:<none>,
iface:[((Int,Int), (Int,Int))],
body:[typ:(Int,Int), accept:Pair, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:6; descr:[Pair; [(0, y)]; Times({id:7; descr:[Any; [(0, y)]; Capture(0, y)]; accept:[id:182; descr:Any]; fv:[(0, y)]}, {id:4; descr:[Any; []; Constr(Any)]; accept:[id:179; descr:Any]; fv:[]})]; accept:[id:181; descr:Pair]; fv:[(0, y)]};
body:{typ:(Int,Int), descr:{typ:(Int,Int); descr=({typ:Int; descr=Var(0, x)}, {typ:Int; descr=Var(0, y)})}}}], typ:X1 -> X1 where X1 = (Int,Int), fv:[(0, x)])}}}], typ:X1 -> X1 -> X1 where X1 = (Int,Int), fv:[])}).({typ:(Int,Int); descr=({typ:Int; descr=Integer(2)}, {typ:Int; descr=Integer(3)})})}).({typ:(Int,Int); descr=({typ:Int; descr=Integer(1)}, {typ:Int; descr=Integer(5)})})}
{typ:X1 -> X1 where X1 = [ Char* ] | Int; descr=Abstraction(name:<none>,
iface:[([ Char* ] | Int, [ Char* ] | Int)],
body:[typ:[ Char* ] | Int, accept:Any, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:3; descr:[Any; [(0, x)]; Capture(0, x)]; accept:[id:176; descr:Any]; fv:[(0, x)]};
body:{typ:[ Char* ] | Int, descr:{typ:[ Char* ] | Int; descr=Match({typ:[ Char* ] | Int; descr=Var(0, x)},typ:[ Char* ] | Int, accept:[ Char* ] | Int, branches:
{used:true; ghost:false; br_vars_empty:[];
pat:{id:4; descr:[Int; []; Constr(Int)]; accept:[id:177; descr:Int]; fv:[]};
body:{typ:[ Char* ] | Int, descr:{typ:[ Char* ] | Int; descr=Integer(2)}}},
{used:true; ghost:false; br_vars_empty:[];
pat:{id:5; descr:[String; []; Constr(String)]; accept:[id:178; descr:String]; fv:[]};
body:{typ:[ Char* ] | Int, descr:{typ:[ Char* ] | Int; descr="Piece of cake"}}})}}}], typ:X1 -> X1 where X1 = [ Char* ] | Int, fv:[])}
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