Commit 31b36113 authored by Julien Lopez's avatar Julien Lopez

Rename tests/ocaml/a to tests/ocaml/misc

parent 611950dc
......@@ -11,7 +11,7 @@ ifneq ($(ML_INTERFACE), false)
INSTALL_BINARIES += cduce_mktop
endif
OUNIT_TESTS=a eval cdnum cdsdl
OUNIT_TESTS=eval cdnum cdsdl misc
ifeq ($(NATIVE),true)
all: cduce_lib.cmxa
......@@ -292,7 +292,7 @@ clean:
rm -rf lib
$(RM) tests/schema/regtest/test.cd tests/schema/regtest/test.log
$(RM) tests/schema/test.cd tests/schema/test.log tests/misc/log tests/misc/memento.html tests/xsltmark/log tests/cql/log
$(RM) oUnit-* tests/ocaml/a/c.ml tests/ocaml/a/c.cdo tests/ocaml/a/c.cmi tests/ocaml/a/c.cmo tests/ocaml/latypes/latypes2* tests/ocaml/latypes/latypes tests/ocaml/latypes/latypes.c[dm][oxi] tests/ocaml/latypes/latypestest.cm[io]
$(RM) oUnit-* tests/ocaml/misc/consts.ml tests/ocaml/misc/consts.cdo tests/ocaml/misc/consts.cmi tests/ocaml/misc/consts.cmo tests/ocaml/latypes/latypes2* tests/ocaml/latypes/latypes tests/ocaml/latypes/latypes.c[dm][oxi] tests/ocaml/latypes/latypestest.cm[io]
for i in $(OUNIT_TESTS); do $(RM) `echo tests/ocaml/$$i/$$i tests/ocaml/$$i/$$i.ml tests/ocaml/$$i/$$i.c[dm][oxi] tests/ocaml/$$i/$${i}test.cm[io]`; done
distclean: clean
......
......@@ -17,7 +17,7 @@ let pp (x : t) : Latin1 = string_of x
let exists = Sys.file_exists
let i = c.j
let i = consts.j
let home = Sys.getenv "HOME"
......
......@@ -19,73 +19,73 @@ let mod_float (x,y) = x -. float_of_int(int_of_float (x /. y)) *. y
let tests = "A" >:::
[
"f" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test A.f.1 failed" "Hello!" (A.f id "Hello!");
assert_equal ~msg:"Test A.f.2 failed" "Uryyb!" (A.f rot13 "Hello!")
assert_equal ~msg:"Test Misc.f.1 failed" "Hello!" (Misc.f id "Hello!");
assert_equal ~msg:"Test Misc.f.2 failed" "Uryyb!" (Misc.f rot13 "Hello!")
);
"g" >:: ( fun test_ctxt ->
A.x := 'b';
assert_equal ~msg:"Test A.g.1 failed" 'b' !A.x;
A.g A.x;
assert_equal ~msg:"Test A.g.2 failed" 'a' !A.x;
A.g A.x;
assert_equal ~msg:"Test A.g.3 failed" 'a' !A.x;
Misc.x := 'b';
assert_equal ~msg:"Test Misc.g.1 failed" 'b' !Misc.x;
Misc.g Misc.x;
assert_equal ~msg:"Test Misc.g.2 failed" 'a' !Misc.x;
Misc.g Misc.x;
assert_equal ~msg:"Test Misc.g.3 failed" 'a' !Misc.x;
);
"re" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test A.re.1 failed" 0.2 (A.re { A.x=0.2; A.y=0.8 })
assert_equal ~msg:"Test Misc.re.1 failed" 0.2 (Misc.re { Misc.x=0.2; Misc.y=0.8 })
);
"diag" >:: ( fun test_ctxt ->
let res : A.complex = { A.x=3.14; A.y=3.14 } in
assert_equal ~msg:"Test A.diag.1 failed" res (A.diag 3.14)
let res : Misc.complex = { Misc.x=3.14; Misc.y=3.14 } in
assert_equal ~msg:"Test Misc.diag.1 failed" res (Misc.diag 3.14)
);
"map_complex" >:: ( fun test_ctxt ->
let res : A.complex = { A.x=0.7; A.y=0.7 } in
assert_equal ~msg:"Test A.map_complex.1 failed"
(hypot res.A.x res.A.y) (A.map_complex norm res);
let res2 : A.complex = { A.x=18.6; A.y=4.2 } in
assert_equal ~msg:"Test A.map_complex.2 failed"
(mod_float (res2.A.x, res2.A.y)) (A.map_complex mod_float res2)
let res : Misc.complex = { Misc.x=0.7; Misc.y=0.7 } in
assert_equal ~msg:"Test Misc.map_complex.1 failed"
(hypot res.Misc.x res.Misc.y) (Misc.map_complex norm res);
let res2 : Misc.complex = { Misc.x=18.6; Misc.y=4.2 } in
assert_equal ~msg:"Test Misc.map_complex.2 failed"
(mod_float (res2.Misc.x, res2.Misc.y)) (Misc.map_complex mod_float res2)
);
"pp" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test A.pp.1 failed" "(`C,3)" (A.pp (A.C(3)));
assert_equal ~msg:"Test A.pp.2 failed"
"(`A,(`C,3))" (A.pp (A.A(A.C(3))));
assert_equal ~msg:"Test A.pp.3 failed"
"(`B,((`C,3),(`A,(`C,2))))" (A.pp (A.B(A.C(3),A.A(A.C(2)))));
assert_equal ~msg:"Test Misc.pp.1 failed" "(`C,3)" (Misc.pp (Misc.C(3)));
assert_equal ~msg:"Test Misc.pp.2 failed"
"(`A,(`C,3))" (Misc.pp (Misc.A(Misc.C(3))));
assert_equal ~msg:"Test Misc.pp.3 failed"
"(`B,((`C,3),(`A,(`C,2))))" (Misc.pp (Misc.B(Misc.C(3),Misc.A(Misc.C(2)))));
);
"exists" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test A.exists.1 failed" false (A.exists "toto.tmp");
assert_equal ~msg:"Test Misc.exists.1 failed" false (Misc.exists "toto.tmp");
let file = bracket_tmpfile test_ctxt in match file with
| (name, _) -> assert_equal
~msg:"Test A.exists.2 failed" true (A.exists name);
~msg:"Test Misc.exists.2 failed" true (Misc.exists name);
);
"str_len" >:: ( fun test_ctxt ->
let str = "This is an example." in
assert_equal ~msg:"Test A.str_len.1 failed" 19 (A.str_len str);
assert_equal ~msg:"Test A.str_len.2 failed" 23 (A.str_len (str^"hack"));
assert_equal ~msg:"Test Misc.str_len.1 failed" 19 (Misc.str_len str);
assert_equal ~msg:"Test Misc.str_len.2 failed" 23 (Misc.str_len (str^"hack"));
);
"unix_write" >:: ( fun test_ctxt ->
let h = Sys.getenv "HOME" in
assert_equal ~msg:"Test A.unix_write.easy failed"
(String.length h) (A.unix_write Unix.stderr h 0 (String.length h));
assert_equal ~msg:"Test A.unix_write.hard failed"
(A.str_len A.home) (A.unix_write A.stdin A.home 0 (A.str_len A.home))
assert_equal ~msg:"Test Misc.unix_write.easy failed"
(String.length h) (Misc.unix_write Unix.stderr h 0 (String.length h));
assert_equal ~msg:"Test Misc.unix_write.hard failed"
(Misc.str_len Misc.home) (Misc.unix_write Misc.stdin Misc.home 0 (Misc.str_len Misc.home))
);
"listmap" >:: ( fun test_ctxt ->
let bioi = Big_int.big_int_of_int in
let lst = A.listmap (fun x -> Big_int.mult_int_big_int 2 x)
let lst = Misc.listmap (fun x -> Big_int.mult_int_big_int 2 x)
[ bioi 10; bioi 20; bioi 30 ] in
let rec test_each lst refs = match lst,refs with
| (el :: rest), (el2 :: rest2) -> assert_equal
~msg:"Test A.listmap.1 failed" 0 (Big_int.compare_big_int el el2);
~msg:"Test Misc.listmap.1 failed" 0 (Big_int.compare_big_int el el2);
test_each rest rest2
| [], [] -> assert true
| _ -> assert false
......@@ -94,8 +94,8 @@ let tests = "A" >:::
);
"misc" >:: ( fun test_ctxt ->
assert_equal ~msg:"Test A.misc.1 failed" (Sys.getenv "HOME") A.home;
assert_equal ~msg:"Test A.misc.2 failed" 2 A.i;
assert_equal ~msg:"Test Misc.misc.1 failed" (Sys.getenv "HOME") Misc.home;
assert_equal ~msg:"Test Misc.misc.2 failed" 2 Misc.i;
);
]
......
......@@ -47,13 +47,13 @@ echo " passed."
echo "Tests on ocamlinterface: "
ocamlc -I $OCAMLDIR/a -c $OCAMLDIR/a/a.mli
$ROOT/../cduce -I $OCAMLDIR/a --compile $OCAMLDIR/a/c.cd
$ROOT/../cduce -I $OCAMLDIR/a --compile $OCAMLDIR/a/a.cd
$ROOT/../cduce -I $OCAMLDIR/a --mlstub $OCAMLDIR/a/c.cdo > $OCAMLDIR/a/c.ml
$ROOT/../cduce -I $OCAMLDIR/a --mlstub $OCAMLDIR/a/a.cdo > $OCAMLDIR/a/a.ml
ocamlfind ocamlc -I $OCAMLDIR/a -g -package cduce,oUnit -linkpkg -o $OCAMLDIR/a/a $OCAMLDIR/a/c.ml $OCAMLDIR/a/a.ml $OCAMLDIR/a/atest.ml
$OCAMLDIR/a/a 2> /dev/null
ocamlc -I $OCAMLDIR/misc -c $OCAMLDIR/misc/misc.mli
$ROOT/../cduce -I $OCAMLDIR/misc --compile $OCAMLDIR/misc/consts.cd
$ROOT/../cduce -I $OCAMLDIR/misc --compile $OCAMLDIR/misc/misc.cd
$ROOT/../cduce -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/consts.cdo > $OCAMLDIR/misc/consts.ml
$ROOT/../cduce -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/misc.cdo > $OCAMLDIR/misc/misc.ml
ocamlfind ocamlc -I $OCAMLDIR/misc -g -package cduce,oUnit -linkpkg -o $OCAMLDIR/misc/misc $OCAMLDIR/misc/consts.ml $OCAMLDIR/misc/misc.ml $OCAMLDIR/misc/misctest.ml
$OCAMLDIR/misc/misc 2> /dev/null
ocamlc -I $OCAMLDIR/eval -c $OCAMLDIR/eval/eval.mli
$ROOT/../cduce -I $OCAMLDIR/eval --compile $OCAMLDIR/eval/eval.cd -I $OCAML_TOPLEVEL_PATH/../cduce
......
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