summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2000-11-13 14:57:54 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2000-11-13 14:57:54 +0000
commit55e87fc472b6bad71fef9ec2bfb4305695350c9a (patch)
tree666aa079b709700437c282da21f8cc54fd0e38a9 /test
parent881322435720addc24e458257a76cdc9572d8137 (diff)
downloadocaml-55e87fc472b6bad71fef9ec2bfb4305695350c9a.tar.gz
Plus de tests sur l'egalite
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@3331 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'test')
-rw-r--r--test/Moretest/equality.ml57
1 files changed, 54 insertions, 3 deletions
diff --git a/test/Moretest/equality.ml b/test/Moretest/equality.ml
index 4f3f9048b1..171735d1db 100644
--- a/test/Moretest/equality.ml
+++ b/test/Moretest/equality.ml
@@ -1,8 +1,59 @@
+let test n exp res =
+ prerr_string "Test "; prerr_int n;
+ if exp = res then prerr_string " passed.\n" else prerr_string " FAILED.\n";
+ flush stderr
+
let x = [1;2;3]
let f x = 1 :: 2 :: 3 :: x
+let mklist len =
+ let l = ref [] in
+ for i = 1 to len do l := i :: !l done;
+ !l
+
+type tree = Dummy | Leaf | Node of tree * tree
+
+let rec mktree depth =
+ if depth <= 0 then Leaf else Node(mktree(depth - 1), mktree(depth - 1))
+
+type 'a leftlist = Nil | Cons of 'a leftlist * 'a
+
+let mkleftlist len =
+ let l = ref Nil in
+ for i = 1 to len do l := Cons(!l, i) done;
+ !l
+
let _ =
- if x = f [] then print_string "OK " else print_string "failed! ";
- if stdout <> stderr then print_string "OK" else print_string "failed!";
- print_newline()
+ test 1 0 (compare 0 0);
+ test 2 (-1) (compare 0 1);
+ test 3 1 (compare 1 0);
+ test 4 0 (compare max_int max_int);
+ test 5 (-1) (compare min_int max_int);
+ test 6 1 (compare max_int min_int);
+ test 7 0 (compare "foo" "foo");
+ test 8 (-1) (compare "foo" "zorglub");
+ test 9 (-1) (compare "abcdef" "foo");
+ test 10 (-1) (compare "abcdefghij" "abcdefghijkl");
+ test 11 1 (compare "abcdefghij" "abcdefghi");
+ test 12 0 (compare (0,1) (0,1));
+ test 13 (-1) (compare (0,1) (0,2));
+ test 14 (-1) (compare (0,1) (1,0));
+ test 15 1 (compare (0,1) (0,0));
+ test 16 1 (compare (1,0) (0,1));
+ test 17 0 (compare 0.0 0.0);
+ test 18 (-1) (compare 0.0 1.0);
+ test 19 (-1) (compare (-1.0) 0.0);
+ test 20 0 (compare [| 0.0; 1.0; 2.0 |] [| 0.0; 1.0; 2.0 |]);
+ test 21 (-1) (compare [| 0.0; 1.0; 2.0 |] [| 0.0; 1.0; 3.0 |]);
+ test 22 1 (compare [| 0.0; 5.0; 2.0 |] [| 0.0; 1.0; 2.0 |]);
+ test 23 0 (compare [1;2;3;4] [1;2;3;4]);
+ test 24 (-1) (compare [1;2;3;4] [1;2;5;6]);
+ test 25 (-1) (compare [1;2;3;4] [1;2;3;4;5]);
+ test 26 1 (compare [1;2;3;4] [1;2;3]);
+ test 27 1 (compare [1;2;3;4] [1;2;0;4]);
+ test 28 0 (compare (mklist 1000) (mklist 1000));
+ test 29 0 (compare (mkleftlist 1000) (mkleftlist 1000));
+ test 30 0 (compare (mktree 12) (mktree 12));
+ test 31 true (x = f []);
+ test 32 true (stdout <> stderr)