Commit 5e86318a authored by Julien Lopez's avatar Julien Lopez

[TESTS] Add list in stdlib; add stdlib in test suite

parent efe6fa1e
let length (l : [('a)*]) : Int =
let aux (l : [('a)*])(res : Int) : Int = match l with
| [] -> res
| [_; rest] -> aux rest (res + 1) in
aux l 0
let hd ([('a)+] -> 'a) [el _*] -> el
let tl ([('a)+] -> [('a)*])
| [el] -> [el]
| [_; t] -> t
(* Iterators *)
let iter (f : ('a -> []))(l : [('a)*]) : [] = match l with
| [] -> []
| [el rest::('a)*] -> f el; iter f rest
include "list.cd"
let nb_success = ref Int (0)
let nb_tests = ref Int (0)
(* Note: We are using List.iter here *)
let run_test_suite (l : [(Latin1, ('a), ('a)) *]) : [] = match l with
| [] -> []
| [(_, x, y) rest::(Latin1, ('a), ('a))*] -> nb_tests := !nb_tests + 1;
(if x = y then nb_success := !nb_success + 1 else []);
run_test_suite rest
let run_test_suite_debug (l : [(Latin1, ('a), ('a)) *]) : [] = match l with
| [] -> []
| [(msg, x, y) rest::(Latin1, ('a), ('a))*] -> nb_tests := !nb_tests + 1;
(if not (x = y) then print msg; print "\nExpected: "; print (string_of y);
print "\nGot:"; print (string_of x); print "\n"
else nb_success := !nb_success + 1); run_test_suite rest
(* Tests *)
let length_tests = [
("Test stdlib.length.1 failed", length [2 5 4], 3)
("Test stdlib.length.2 failed", length [], 0)
] in
let hd_tests = [
("Test stdlib.hd.1 failed", hd [1], 1)
("Test stdlib.hd.2 failed", hd [2 5 4], 2)
] in
let tl_tests = [
("Test stdlib.tl.1 failed", tl [1], [1])
("Test stdlib.tl.2 failed", tl [2 5 4], [5 4])
] in
(* Run tests *)
run_test_suite length_tests;
run_test_suite hd_tests;
run_test_suite tl_tests;
print (string_of !nb_success); print " / "; print (string_of !nb_tests)
......@@ -15,6 +15,8 @@ EXTENDED="false"
# Error code: 0 success; 1 failure.
RET=0
CDUCE="$ROOT/../cduce"
# Parse options
while test $# -ne 0; do
......@@ -22,6 +24,15 @@ while test $# -ne 0; do
shift;
done
# Test stdlib
STDLIBDIR=$ROOT/stdlib
echo -n "Tests on stdlib: "
$CDUCE $ROOT/stdlib/list/listtest.cd 2> /dev/null
test $? -ne 0 && RET=1
echo " passed."
# Test schema
SCHEMADIR=$ROOT/schema
......@@ -70,14 +81,14 @@ if test $EXTENDED = "true"; then GOODTESTS="$GOODTESTS $EXTENDEDTESTS"; fi
for i in db100.xml db10.xml; do
TOTAL=$(($TOTAL+1))
echo "==============dbonerow.cd --arg $i===============" >> $XSLTLOG;
$ROOT/../cduce $ROOT/xsltmark/dbonerow.cd --arg $ROOT/xsltmark/testcases/$i > /dev/null 2>> $XSLTLOG;
$CDUCE $ROOT/xsltmark/dbonerow.cd --arg $ROOT/xsltmark/testcases/$i > /dev/null 2>> $XSLTLOG;
if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done
for i in $GOODTESTS; do
TOTAL=$(($TOTAL+1))
echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $XSLTLOG;
$ROOT/../cduce $i > /dev/null 2>> $XSLTLOG;
$CDUCE $i > /dev/null 2>> $XSLTLOG;
if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done
......@@ -101,7 +112,7 @@ if test $EXTENDED = "true"; then GOODTESTS="$GOODTESTS $EXTENDEDTESTS"; fi
for i in $GOODTESTS; do
TOTAL=$(($TOTAL+1))
echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $CQLLOG;
$ROOT/../cduce $i > /dev/null 2>> $CQLLOG;
$CDUCE $i > /dev/null 2>> $CQLLOG;
if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done
......@@ -123,7 +134,7 @@ GOODTESTS="$ROOT/misc/addrbook.cd $ROOT/misc/biblio.cd\
$ROOT/misc/security.cd $ROOT/misc/str.cd $ROOT/misc/stress_opt_arg.cd\
$ROOT/misc/stress_opt_seq.cd $ROOT/misc/vouill.cd $ROOT/misc/web.cd\
$ROOT/misc/wp.cd $ROOT/misc/xtrans.cd $ROOT/misc/ref.cd $ROOT/misc/xhtml.cd\
$ROOT/misc/polysyntax.cd"
$ROOT/misc/polysyntax.cd $ROOT/misc/polyfuns.cd"
BADTESTS="$ROOT/misc/bugs_prod.cd $ROOT/misc/eval_concat.cd"
EXTENDEDTESTS="$ROOT/misc/html2latex.cd"
......@@ -134,14 +145,14 @@ if test $EXTENDED = "true"; then GOODTESTS="$GOODTESTS $EXTENDEDTESTS"; fi
for i in $GOODTESTS; do
TOTAL=$(($TOTAL+1))
echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $MISCLOG;
$ROOT/../cduce $i > /dev/null 2>> $MISCLOG;
$CDUCE $i > /dev/null 2>> $MISCLOG;
if test $? -eq 0; then SUCCESS=$(($SUCCESS+1)); fi
done
for i in $BADTESTS; do
TOTAL=$(($TOTAL+1))
echo "==============`echo $i | rev | cut -d "/" -f -1 | rev`===============" >> $MISCLOG;
$ROOT/../cduce $i > /dev/null 2>> $MISCLOG;
$CDUCE $i > /dev/null 2>> $MISCLOG;
if test $? -ne 0; then SUCCESS=$(($SUCCESS+1)); fi
done
......@@ -160,39 +171,39 @@ if test $WITHOCAML = "true"; then
echo "Tests on ocamlinterface: "
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
$CDUCE -I $OCAMLDIR/misc --compile $OCAMLDIR/misc/consts.cd
$CDUCE -I $OCAMLDIR/misc --compile $OCAMLDIR/misc/misc.cd
$CDUCE -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/consts.cdo > $OCAMLDIR/misc/consts.ml
$CDUCE -I $OCAMLDIR/misc --mlstub $OCAMLDIR/misc/misc.cdo > $OCAMLDIR/misc/misc.ml
ocamlfind ocamlc -I $OCAMLDIR/misc -g -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/misc/misc $OCAMLDIR/misc/consts.ml $OCAMLDIR/misc/misc.ml $OCAMLDIR/misc/misctest.ml
$OCAMLDIR/misc/misc 2> /dev/null
test $? -ne 0 && RET=1
ocamlc -I $OCAMLDIR/eval -c $OCAMLDIR/eval/eval.mli
$ROOT/../cduce -I $OCAMLDIR/eval --compile $OCAMLDIR/eval/eval.cd -I $ROOT/../lib
$ROOT/../cduce -I $OCAMLDIR/eval --mlstub $OCAMLDIR/eval/eval.cdo > $OCAMLDIR/eval/eval.ml
$CDUCE -I $OCAMLDIR/eval --compile $OCAMLDIR/eval/eval.cd -I $ROOT/../lib
$CDUCE -I $OCAMLDIR/eval --mlstub $OCAMLDIR/eval/eval.cdo > $OCAMLDIR/eval/eval.ml
ocamlfind ocamlc -I $OCAMLDIR/eval -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/eval/eval $OCAMLDIR/eval/eval.ml $OCAMLDIR/eval/evaltest.ml
$OCAMLDIR/eval/eval
test $? -ne 0 && RET=1
ocamlc -I $OCAMLDIR/cdnum -c $OCAMLDIR/cdnum/cdnum.mli
$ROOT/../cduce -I $OCAMLDIR/cdnum --compile $OCAMLDIR/cdnum/cdnum.cd -I `ocamlfind query num`
$ROOT/../cduce -I $OCAMLDIR/cdnum --mlstub $OCAMLDIR/cdnum/cdnum.cdo > $OCAMLDIR/cdnum/cdnum.ml
$CDUCE -I $OCAMLDIR/cdnum --compile $OCAMLDIR/cdnum/cdnum.cd -I `ocamlfind query num`
$CDUCE -I $OCAMLDIR/cdnum --mlstub $OCAMLDIR/cdnum/cdnum.cdo > $OCAMLDIR/cdnum/cdnum.ml
ocamlfind ocamlc -I $OCAMLDIR/cdnum -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,num,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/cdnum/cdnum $OCAMLDIR/cdnum/cdnum.ml $OCAMLDIR/cdnum/cdnumtest.ml
$OCAMLDIR/cdnum/cdnum
test $? -ne 0 && RET=1
if test $EXTENDED = "true"; then
ocamlc -I $OCAMLDIR/cdsdl -c -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.mli
$ROOT/../cduce -I $OCAMLDIR/cdsdl --compile -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cd
$ROOT/../cduce -I $OCAMLDIR/cdsdl --mlstub -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cdo > $OCAMLDIR/cdsdl/cdsdl.ml
$CDUCE -I $OCAMLDIR/cdsdl --compile -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cd
$CDUCE -I $OCAMLDIR/cdsdl --mlstub -I `ocamlfind query sdl` $OCAMLDIR/cdsdl/cdsdl.cdo > $OCAMLDIR/cdsdl/cdsdl.ml
ocamlfind ocamlc -I $OCAMLDIR/cdsdl -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,sdl,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/cdsdl/cdsdl $OCAMLDIR/cdsdl/cdsdl.ml $OCAMLDIR/cdsdl/cdsdltest.ml
$OCAMLDIR/cdsdl/cdsdl
test $? -ne 0 && RET=1
ocamlc -I $OCAMLDIR/latypes -c $OCAMLDIR/latypes/latypes.mli
$ROOT/../cduce -I $OCAMLDIR/latypes --compile $OCAMLDIR/latypes/latypes.cd
$ROOT/../cduce -I $OCAMLDIR/latypes --mlstub $OCAMLDIR/latypes/latypes.cdo > $OCAMLDIR/latypes/latypes2.ml
$CDUCE -I $OCAMLDIR/latypes --compile $OCAMLDIR/latypes/latypes.cd
$CDUCE -I $OCAMLDIR/latypes --mlstub $OCAMLDIR/latypes/latypes.cdo > $OCAMLDIR/latypes/latypes2.ml
ocamlfind ocamlc -I $OCAMLDIR/latypes -package expat,pxp,curl,camlp4.lib,oUnit,num,netstring,pcre,ulex,num,oUnit -linkpkg -I lib lib/cduce_lib.cma -o $OCAMLDIR/latypes/latypes $OCAMLDIR/latypes/latypes.ml $OCAMLDIR/latypes/latypes2.ml $OCAMLDIR/latypes/latypestest.ml
$OCAMLDIR/latypes/latypes
test $? -ne 0 && RET=1
......
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