summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--otherlibs/num/test/test.ml12
-rw-r--r--otherlibs/num/test/test_big_ints.ml9
2 files changed, 17 insertions, 4 deletions
diff --git a/otherlibs/num/test/test.ml b/otherlibs/num/test/test.ml
index 1458fdcb8..67d1d50b0 100644
--- a/otherlibs/num/test/test.ml
+++ b/otherlibs/num/test/test.ml
@@ -14,7 +14,8 @@ let test test_number eq_fun (answer, correct_answer) =
flush stdout;
flush stderr;
if not (eq_fun answer correct_answer) then begin
- fprintf stderr ">>> Bad result (%s, test %d)\n" !function_tested test_number;
+ fprintf stderr "*** Bad result (%s, test %d)\n" !function_tested test_number;
+ flush stderr;
error_occurred := true;
false
end else begin
@@ -27,8 +28,9 @@ let failure_test test_number fun_to_test arg =
flush stderr;
try
fun_to_test arg;
- fprintf stderr ">>> Failure expected (%s, test %d)\n"
+ fprintf stderr "*** Failure expected (%s, test %d)\n"
!function_tested test_number;
+ flush stderr;
error_occurred := true;
false
with _ ->
@@ -38,8 +40,9 @@ let failure_test test_number fun_to_test arg =
let failwith_test test_number fun_to_test arg correct_failure =
try
fun_to_test arg;
- fprintf stderr ">>> Failure expected (%s, test %d)\n"
+ fprintf stderr "*** Failure expected (%s, test %d)\n"
!function_tested test_number;
+ flush stderr;
error_occurred := true;
false
with x ->
@@ -47,8 +50,9 @@ let failwith_test test_number fun_to_test arg correct_failure =
printf " %d..." test_number;
true
end else begin
- fprintf stderr ">>> Bad failure (%s, test %d)\n"
+ fprintf stderr "*** Bad failure (%s, test %d)\n"
!function_tested test_number;
+ flush stderr;
error_occurred := true;
false
end
diff --git a/otherlibs/num/test/test_big_ints.ml b/otherlibs/num/test/test_big_ints.ml
index 5ccadfd02..858dba270 100644
--- a/otherlibs/num/test/test_big_ints.ml
+++ b/otherlibs/num/test/test_big_ints.ml
@@ -389,3 +389,12 @@ test 3
eq_big_int (base_power_big_int 10 1 (big_int_of_int 123), big_int_of_int 1230)
;;
+testing_function "square_big_int";;
+test 1 eq
+ (square_big_int (big_int_of_string "0"), big_int_of_string"0");;
+test 2 eq_big_int
+ (square_big_int (big_int_of_string "1"), big_int_of_string"1");;
+test 3 eq_big_int
+ (square_big_int (big_int_of_string "-1"), big_int_of_string"1");;
+test 4 eq_big_int
+ (square_big_int (big_int_of_string "-7"), big_int_of_string"49");;