[m-rev.] diff: update some tests

Peter Wang novalazy at gmail.com
Wed Aug 10 15:12:41 AEST 2011


Branches: main, 11.07

tests/hard_coded/big_array_from_list.m:
tests/hard_coded/hash_table_test.m:
tests/hard_coded/version_hash_table_test2.m:
tests/hard_coded/tree_bitset_tester.m:
	Bring these modules up to date with respect to library changes.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_tree_bitset.exp:
tests/hard_coded/test_tree_bitset.m:
	Enable test_tree_bitset test case.

	Fix condition which prevented BIG_DATA_PROGS being tested.

diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index 5c0c6fe..d3190a0 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -283,6 +283,7 @@ ORDINARY_PROGS=	\
 	test_pretty_printer \
 	test_pretty_printer_defaults \
 	test_semaphore \
+	test_tree_bitset \
 	test_yield \
 	tim_qual1 \
 	time_test \
@@ -443,7 +444,7 @@ endif
 # execute them in grades that do not allow tail recursion, since their failures
 # would be spurious.
 
-ifneq "$(filter debug% deep%,$(GRADE))" ""
+ifeq "$(findstring debug,$(GRADE))$(findstring deep,$(GRADE))" ""
 	BIG_DATA_PROGS = \
 		big_array_from_list \
 		hash_table_test \
diff --git a/tests/hard_coded/big_array_from_list.m b/tests/hard_coded/big_array_from_list.m
index 80b40f4..f1ffdd7 100644
--- a/tests/hard_coded/big_array_from_list.m
+++ b/tests/hard_coded/big_array_from_list.m
@@ -42,7 +42,7 @@ array_from_list(List, Array) :-
 
 array_insert_items([], _N, Array, Array).
 array_insert_items([Head | Tail], N, Array0, Array) :-
-    array.set(Array0, N, Head, Array1),
+    array.set(N, Head, Array0, Array1),
     N1 = N + 1,
     array_insert_items(Tail, N1, Array1, Array).
 
diff --git a/tests/hard_coded/hash_table_test.m b/tests/hard_coded/hash_table_test.m
index 98c449c..8a5fa92 100644
--- a/tests/hard_coded/hash_table_test.m
+++ b/tests/hard_coded/hash_table_test.m
@@ -36,17 +36,17 @@ main(!IO) :-
     Max = string.det_to_int(A),
     MaxOccupancy = string.det_to_float(B),
     some [!HT] (
-        !:HT = hash_table.new(int_hash, 1, MaxOccupancy),
+        !:HT = hash_table.init(int_hash, 1, MaxOccupancy),
 
         io.write_string("Inserting elements\n", !IO),
         int.fold_up(do_insert, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
         io.write_string("Looking up elements\n", !IO),
         int.fold_up(do_lookup, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
@@ -62,7 +62,7 @@ main(!IO) :-
         Half = Max / 2,
         io.write_string("Deleting some elements\n", !IO),
         int.fold_up(do_delete, 0, Half - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
@@ -84,13 +84,13 @@ main(!IO) :-
 
         io.write_string("Replacing elements\n", !IO),
         int.fold_up(do_replace_neg, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
         io.write_string("Looking up elements\n", !IO),
         int.fold_up(do_lookup_neg, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
diff --git a/tests/hard_coded/test_tree_bitset.exp b/tests/hard_coded/test_tree_bitset.exp
index e69de29..61335ee 100644
--- a/tests/hard_coded/test_tree_bitset.exp
+++ b/tests/hard_coded/test_tree_bitset.exp
@@ -0,0 +1,90 @@
+List1: 2, 7, 15, 19, 19, 22, 25, 28, 29, 31, 32, 34, 36, 38, 39, 40, 42, 44, 47, 58, 59, 59
+
+List2: 2, 4, 4, 9, 11, 12, 13, 14, 17, 18, 21, 23, 23, 30, 31, 37, 37, 38, 39, 40, 42, 43, 44, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 61, 61, 63, 64
+
+testing count
+count: 20 35
+testing foldl
+Sum of List1 = 647
+Sum of List2 = 1305
+testing union
+[2, 4, 7, 9, 11, 12, 13, 14, 15, 17, 18, 19, 21, 22, 23, 25, 28, 29, 30, 31, 32, 34, 36, 37, 38, 39, 40, 42, 43, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 61, 63, 64]
+testing intersection
+[2, 31, 38, 39, 40, 42, 44, 58]
+testing difference
+[7, 15, 19, 22, 25, 28, 29, 32, 34, 36, 47, 59]
+testing remove_least_element
+2
+[7, 15, 19, 22, 25, 28, 29, 31, 32, 34, 36, 38, 39, 40, 42, 44, 47, 58, 59]
+testing delete_list
+[7, 15, 19, 22, 25, 28, 29, 32, 34, 36, 47, 59]
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
+testing count
+testing foldl
+testing union
+testing intersection
+testing difference
+testing remove_least_element
+testing delete_list
diff --git a/tests/hard_coded/test_tree_bitset.m b/tests/hard_coded/test_tree_bitset.m
index a5900dd..d6bb1d0 100644
--- a/tests/hard_coded/test_tree_bitset.m
+++ b/tests/hard_coded/test_tree_bitset.m
@@ -38,6 +38,7 @@ main(!IO) :-
 
     % Run some more tests with random input, checking
     % the output against that of set_ordlist.
+    % XXX this is wholly inadequate
     Iterations = 10,
     random.init(1, Supply),
     run_tests(Iterations, Supply, !IO).
@@ -152,7 +153,7 @@ run_test(Write, List1, List2, !IO) :-
     write_bitset_result(Write, Delete, !IO),
 
     require(unify(delete_list(Set1, List1),
-            init `with_type` tree_bitset_tester(int)),
+            init : tree_bitset_tester.bitset_tester(int)),
         "delete_list_failed").
 
 :- pred write_bitset_result(bool::in, bitset_tester(int)::in,
diff --git a/tests/hard_coded/tree_bitset_tester.m b/tests/hard_coded/tree_bitset_tester.m
index 1658535..1afdc45 100644
--- a/tests/hard_coded/tree_bitset_tester.m
+++ b/tests/hard_coded/tree_bitset_tester.m
@@ -151,14 +151,14 @@ delete_list(SetA - SetB, List) =
         delete_list(SetA, List) - set.delete_list(SetB, List)).
 
 remove(SetA0 - SetB0, Elem) = Result :-
-    ( SetA1 = remove(SetA0, Elem) ->
-        ( remove(SetB0, Elem, SetB1) ->
+    ( remove(Elem, SetA0, SetA1) ->
+        ( remove(Elem, SetB0, SetB1) ->
             SetA = SetA1,
             SetB = SetB1
         ;
             error("remove succeeded unexpectedly")
         )
-    ; set.remove(SetB0, Elem, _) ->
+    ; set.remove(Elem, SetB0, _) ->
         error("remove failed unexpectedly")
     ;
         fail
@@ -166,14 +166,14 @@ remove(SetA0 - SetB0, Elem) = Result :-
     Result = check("remove", SetA0 - SetB0, SetA - SetB).
 
 remove_list(SetA0 - SetB0, List) = Result :-
-    ( SetA1 = remove_list(SetA0, List) ->
-        ( set.remove_list(SetB0, List, SetB1) ->
+    ( remove_list(List, SetA0, SetA1) ->
+        ( set.remove_list(List, SetB0, SetB1) ->
             SetA = SetA1,
             SetB = SetB1
         ;
             error("remove succeeded unexpectedly")
         )
-    ; set.remove_list(SetB0, List, _) ->
+    ; set.remove_list(List, SetB0, _) ->
         error("remove failed unexpectedly")
     ;
         fail
@@ -284,8 +284,8 @@ difference(SetA1 - SetB1, SetA2 - SetB2) =
 %-----------------------------------------------------------------------------%
 
 remove_least(SetA0 - SetB0, Least, SetA - SetB) :-
-    ( remove_least(SetA0, LeastA, SetA1) ->
-        ( remove_least(SetB0, LeastB, SetB1) ->
+    ( remove_least(LeastA, SetA0, SetA1) ->
+        ( remove_least(LeastB, SetB0, SetB1) ->
             ( LeastA = LeastB ->
                 SetA = SetA1,
                 SetB = SetB1,
@@ -296,7 +296,7 @@ remove_least(SetA0 - SetB0, Least, SetA - SetB) :-
         ;
             error("remove_least: should be no least value")
         )
-    ; remove_least(SetB0, _, _) ->
+    ; remove_least(_, SetB0, _) ->
         error("remove_least: failed")
     ;
         fail
diff --git a/tests/hard_coded/version_hash_table_test2.m b/tests/hard_coded/version_hash_table_test2.m
index 2bdf182..2e35cb1 100644
--- a/tests/hard_coded/version_hash_table_test2.m
+++ b/tests/hard_coded/version_hash_table_test2.m
@@ -36,17 +36,17 @@ main(!IO) :-
     Max = string.det_to_int(A),
     MaxOccupancy = string.det_to_float(B),
     some [!HT] (
-        !:HT = version_hash_table.new(int_hash, 1, MaxOccupancy),
+        !:HT = version_hash_table.init(int_hash, 1, MaxOccupancy),
 
         io.write_string("Inserting elements\n", !IO),
         int.fold_up(do_insert, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
         io.write_string("Looking up elements\n", !IO),
         int.fold_up(do_lookup, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
@@ -60,7 +60,7 @@ main(!IO) :-
         Half = Max / 2,
         io.write_string("Deleting some elements\n", !IO),
         int.fold_up(do_delete, 0, Half - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
@@ -80,13 +80,13 @@ main(!IO) :-
 
         io.write_string("Replacing elements\n", !IO),
         int.fold_up(do_replace_neg, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 
         io.write_string("Looking up elements\n", !IO),
         int.fold_up(do_lookup_neg, 0, Max - 1, !HT),
-        trace [io(!IO), runtime(env("HASH_TABLE_STATS"))] (
+        trace [runtime(env("HASH_TABLE_STATS"))] (
             impure report_stats
         ),
 

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list