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

[TESTS][LAMBDA] Fix string type; add dummy type variables

parent fccd98da
......@@ -27,6 +27,7 @@ id = [a-z_][A-Za-z0-9_]*
(* TODO: Add union and polymorphic types *)
type_id = [A-Z][A-Za-z0-9_]*
| (complex_type_id)
| "'"[A-Z][A-Za-z0-9_]*
complex_type_id = [A-Z][A-Za-z0-9_]*
| complex_type_id * complex_type_id
......
......@@ -13,12 +13,13 @@ exception Error
let type_of_string s = match s with
| "Int" -> interval [Intervals.Any]
| "String" -> char Chars.any (* TODO: This type is char, find string *)
| "String" -> Sequence.string
| "Char" -> char Chars.any
| _ -> empty
let rec type_of_ptype arg = match arg with
| Type(t) -> type_of_string t
| PType(t) -> any (* TODO: Check this solution *)
| TPair(t1, t2) -> times (cons (type_of_ptype t1)) (cons (type_of_ptype t2))
| TArrow(t1, t2) -> arrow (cons (type_of_ptype t1)) (cons (type_of_ptype t2))
......
......@@ -27,7 +27,7 @@ let tests = "CDuce runtime tests" >:::
(run_test "fun f x : Int : Int -> 2");
(* TODO: Fix this test. See compute.ml in type_of_string function *)
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");
);
......
......@@ -19,6 +19,7 @@ and match_value =
| MString of Loc.t * string
and ptype =
| Type of string
| PType of string
| TPair of ptype * ptype
| TArrow of ptype * ptype
......@@ -62,7 +63,8 @@ module ExprParser = struct
];
type_id: [ "atom_type" [ t = UIDENT -> Type(t) ]
| [ "("; t = complex_type_id; ")" -> t ]];
| [ "("; t = complex_type_id; ")" -> t ]
| [ "'"; t = UIDENT -> PType(t) ] ];
complex_type_id: [ "complex_type" LEFTA [ t = UIDENT -> Type(t)
| "("; t = SELF; ")" -> t ]
......
......@@ -18,6 +18,7 @@ and match_value =
| MString of Loc.t * string
and ptype =
| Type of string
| PType of string
| TPair of ptype * ptype
| TArrow of ptype * ptype
......
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