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

[TESTS][LAMBDA][MINOR] Libflags from Makefile to _tags; Add types Char and

	String, String to fix
parent a08b6a2d
......@@ -3,9 +3,6 @@ ROOTDIR ?= ../..
SRCDIR ?= src
EXTDIR ?= $(SRCDIR)/externals
LIBFLAGS ?= -libs nums,netstring,pcre,ulexing\
-lflags -I,`ocamlfind query netstring` -lflags -I,`ocamlfind query pcre`\
-lflags -I,`ocamlfind query ulex`
DEBUGFLAGS ?= -cflags -g -lflags -g
INEXTFILES = misc/custom.ml misc/encodings.ml misc/upool.ml misc/ns.ml\
......@@ -33,10 +30,10 @@ OUTDEBUG ?= main.byte
.PHONY: clean check test _import
all: _import
$(COMPILER) -use-ocamlfind $(LIBFLAGS) $(OUT)
$(COMPILER) -use-ocamlfind $(OUT)
debug: _import
$(COMPILER) -use-ocamlfind $(DEBUGFLAGS) $(LIBFLAGS) $(OUTDEBUG)
$(COMPILER) -use-ocamlfind $(DEBUGFLAGS) $(OUTDEBUG)
_import:
@echo -n "Copying external files..."
......
<src>: include
<src/parse*>: pp(camlp4orf.opt), package(camlp4.lib)
<src/compute*>: pp(camlp4orf.opt), package(camlp4.lib, unix, netsys, str)
<src/main*>: pp(camlp4orf.opt), package(camlp4.lib, unix, netsys, str, oUnit)
<src/main*>: pp(camlp4orf.opt), package(camlp4.lib, unix, netsys, str, oUnit, pcre, ulex, num, netstring)
<src/externals>: include
<src/externals/schema_*>: package(pcre, netcgi2)
......
......@@ -11,17 +11,11 @@ module Locals = Map.Make(String)
(* To throw in case of an unbound name *)
exception Error
(* TODO: We will need a much better representation of types and a much better
function when we'll add union types and polymorphism. *)
let rec is_subtype arg1 arg2 = match arg1, arg2 with
| Type(t), Type(u) -> if String.compare t u = 0 then true else false
| TPair(t1, t2), TPair(u1, u2) -> (is_subtype t1 u1) && (is_subtype t2 u2)
| TArrow(t1, t2), TArrow(u1, u2) -> (is_subtype t1 u1) && (is_subtype t2 u2)
| _ -> false
let type_of_string s = match s with
| "Int" -> interval [Intervals.Any]
| _ -> Types.empty
| "String" -> char Chars.any (* TODO: This type is char, find string *)
| "Char" -> char Chars.any
| _ -> empty
let rec type_of_ptype arg = match arg with
| Type(t) -> type_of_string t
......@@ -174,14 +168,16 @@ and parse_match_value env l list p toptype = match p with
let d1 = any, list, Patterns.Capture(lsize, mname) in
let t2 = type_of_ptype mtype in
let d2 = t2, [], Patterns.Constr(t2) in
t2, Patterns.Cap(d1, d2), list, l, is_subtype toptype mtype
t2, Patterns.Cap(d1, d2), list, l, Types.subtype (type_of_ptype toptype) t2
| MInt (_, i) ->
let t = constant (Integer(big_int_of_int i)) in
t, Patterns.Constr(t), list, l, is_subtype toptype (Type("Int"))
t, Patterns.Constr(t), list, l, Types.subtype (type_of_ptype toptype)
(type_of_string "Int")
| MString (_, s) ->
let t = constant (String(0, String.length s - 1, s,
Integer(big_int_of_int 0))) in
t, Patterns.Constr(t), list, l, is_subtype toptype (Type("String"))
t, Patterns.Constr(t), list, l, Types.subtype (type_of_ptype toptype)
(type_of_string "String")
let to_typed expr =
let env, l, expr = _to_typed empty_toplevel Locals.empty expr in
......
......@@ -25,6 +25,10 @@ let tests = "CDuce runtime tests" >:::
assert_equal ~msg:"Test CDuce.runtime.abstr.simple failed"
~printer:(fun x -> x) "Abstraction((Int, Int))"
(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)))"
(run_test "fun f x : Int y : String : (Int*String) -> x,y");
);
"apply" >:: ( fun test_ctxt ->
......
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