[m-rev.] diff: add tests of comparison operations for fixed size integers
Julien Fischer
jfischer at opturion.com
Sat Aug 26 12:06:21 AEST 2017
Add tests of comparison operations for fixed size integers.
tests/hard_coded/cmp_int{8,16,32}.{m,exp}:
tests/hard_coded/cmp_uint{8,16,32}.{m,exp}:
As above.
tests/hard_coded/Mmakefile:
Add the new tests.
Julien.
diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index a16a859e4..7ea0e9119 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -627,6 +627,12 @@ ifeq "$(findstring profdeep,$(GRADE))" ""
bitmap_empty \
bitmap_test \
bit_buffer_test \
+ cmp_int16 \
+ cmp_int32 \
+ cmp_int8 \
+ cmp_uint16 \
+ cmp_uint32 \
+ cmp_uint8 \
dir_test \
final_excp \
init_excp \
diff --git a/tests/hard_coded/cmp_int16.m b/tests/hard_coded/cmp_int16.m
index e69de29bb..8f7411a73 100644
--- a/tests/hard_coded/cmp_int16.m
+++ b/tests/hard_coded/cmp_int16.m
@@ -0,0 +1,77 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+
+% Test comparison operations for signed 16-bit integers.
+
+:- module cmp_int16.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int16.
+
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+ run_cmp_test(unify, "==", !IO),
+ io.nl(!IO),
+ run_cmp_test(int16.(<), "<", !IO),
+ io.nl(!IO),
+ run_cmp_test(int16.(=<), "=<", !IO),
+ io.nl(!IO),
+ run_cmp_test(int16.(>), ">", !IO),
+ io.nl(!IO),
+ run_cmp_test(int16.(>=), ">=", !IO).
+
+:- pred run_cmp_test(pred(int16, int16)::in(pred(in, in) is semidet),
+ string::in, io::di, io::uo) is det.
+
+run_cmp_test(CmpPred, Desc, !IO) :-
+ io.format("*** Testing int16.'%s' ***\n\n", [s(Desc)], !IO),
+ As = numbers,
+ Bs = numbers,
+ list.foldl(run_cmp_test_2(CmpPred, Desc, Bs), As, !IO).
+
+:- pred run_cmp_test_2(pred(int16, int16)::in(pred(in, in) is semidet),
+ string::in, list(int16)::in, int16::in, io::di, io::uo) is det.
+
+run_cmp_test_2(CmpPred, Desc, Bs, A, !IO) :-
+ list.foldl(run_cmp_test_3(CmpPred, Desc, A), Bs, !IO).
+
+:- pred run_cmp_test_3(pred(int16, int16)::in(pred(in, in) is semidet), string::in,
+ int16::in, int16::in, io::di, io::uo) is det.
+
+run_cmp_test_3(CmpPred, Desc, A, B, !IO) :-
+ Result = ( if CmpPred(A, B) then "true" else "false" ),
+ io.format("%s %s %s = %s\n",
+ [s(int16_to_string(A)), s(Desc), s(int16_to_string(B)), s(Result)], !IO).
+
+:- func numbers = list(int16).
+
+numbers = [
+ -32_768_i16,
+ -128_i16,
+ 0_i16,
+ 1_i16,
+ 2_i16,
+ 8_i16,
+ 10_i16,
+ 16_i16,
+ 127_i16,
+ 32_767_i16
+].
+
+%---------------------------------------------------------------------------%
+:- end_module cmp_int16.
+%---------------------------------------------------------------------------%
diff --git a/tests/hard_coded/cmp_int32.m b/tests/hard_coded/cmp_int32.m
index e69de29bb..662e65cac 100644
--- a/tests/hard_coded/cmp_int32.m
+++ b/tests/hard_coded/cmp_int32.m
@@ -0,0 +1,80 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+
+% Test comparison operations for signed 32-bit integers.
+
+:- module cmp_int32.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int32.
+
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+ run_cmp_test(unify, "==", !IO),
+ io.nl(!IO),
+ run_cmp_test(int32.(<), "<", !IO),
+ io.nl(!IO),
+ run_cmp_test(int32.(=<), "=<", !IO),
+ io.nl(!IO),
+ run_cmp_test(int32.(>), ">", !IO),
+ io.nl(!IO),
+ run_cmp_test(int32.(>=), ">=", !IO).
+
+:- pred run_cmp_test(pred(int32, int32)::in(pred(in, in) is semidet),
+ string::in, io::di, io::uo) is det.
+
+run_cmp_test(CmpPred, Desc, !IO) :-
+ io.format("*** Testing int32.'%s' ***\n\n", [s(Desc)], !IO),
+ As = numbers,
+ Bs = numbers,
+ list.foldl(run_cmp_test_2(CmpPred, Desc, Bs), As, !IO).
+
+:- pred run_cmp_test_2(pred(int32, int32)::in(pred(in, in) is semidet),
+ string::in, list(int32)::in, int32::in, io::di, io::uo) is det.
+
+run_cmp_test_2(CmpPred, Desc, Bs, A, !IO) :-
+ list.foldl(run_cmp_test_3(CmpPred, Desc, A), Bs, !IO).
+
+:- pred run_cmp_test_3(pred(int32, int32)::in(pred(in, in) is semidet), string::in,
+ int32::in, int32::in, io::di, io::uo) is det.
+
+run_cmp_test_3(CmpPred, Desc, A, B, !IO) :-
+ Result = ( if CmpPred(A, B) then "true" else "false" ),
+ io.format("%s %s %s = %s\n",
+ [s(int32_to_string(A)), s(Desc), s(int32_to_string(B)), s(Result)],
+ !IO).
+
+:- func numbers = list(int32).
+
+numbers = [
+ -2_147_483_648_i32,
+ -32_768_i32,
+ -128_i32,
+ 0_i32,
+ 1_i32,
+ 2_i32,
+ 8_i32,
+ 10_i32,
+ 16_i32,
+ 127_i32,
+ 32_767_i32,
+ 2_147_483_647_i32
+].
+
+%---------------------------------------------------------------------------%
+:- end_module cmp_int32.
+%---------------------------------------------------------------------------%
diff --git a/tests/hard_coded/cmp_int8.m b/tests/hard_coded/cmp_int8.m
index e69de29bb..304c3b37e 100644
--- a/tests/hard_coded/cmp_int8.m
+++ b/tests/hard_coded/cmp_int8.m
@@ -0,0 +1,75 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+
+% Test comparison operations for signed 8-bit integers.
+
+:- module cmp_int8.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module int8.
+
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+ run_cmp_test(unify, "==", !IO),
+ io.nl(!IO),
+ run_cmp_test(int8.(<), "<", !IO),
+ io.nl(!IO),
+ run_cmp_test(int8.(=<), "=<", !IO),
+ io.nl(!IO),
+ run_cmp_test(int8.(>), ">", !IO),
+ io.nl(!IO),
+ run_cmp_test(int8.(>=), ">=", !IO).
+
+:- pred run_cmp_test(pred(int8, int8)::in(pred(in, in) is semidet),
+ string::in, io::di, io::uo) is det.
+
+run_cmp_test(CmpPred, Desc, !IO) :-
+ io.format("*** Testing int8.'%s' ***\n\n", [s(Desc)], !IO),
+ As = numbers,
+ Bs = numbers,
+ list.foldl(run_cmp_test_2(CmpPred, Desc, Bs), As, !IO).
+
+:- pred run_cmp_test_2(pred(int8, int8)::in(pred(in, in) is semidet),
+ string::in, list(int8)::in, int8::in, io::di, io::uo) is det.
+
+run_cmp_test_2(CmpPred, Desc, Bs, A, !IO) :-
+ list.foldl(run_cmp_test_3(CmpPred, Desc, A), Bs, !IO).
+
+:- pred run_cmp_test_3(pred(int8, int8)::in(pred(in, in) is semidet), string::in,
+ int8::in, int8::in, io::di, io::uo) is det.
+
+run_cmp_test_3(CmpPred, Desc, A, B, !IO) :-
+ Result = ( if CmpPred(A, B) then "true" else "false" ),
+ io.format("%s %s %s = %s\n",
+ [s(int8_to_string(A)), s(Desc), s(int8_to_string(B)), s(Result)], !IO).
+
+:- func numbers = list(int8).
+
+numbers = [
+ -128_i8,
+ 0_i8,
+ 1_i8,
+ 2_i8,
+ 8_i8,
+ 10_i8,
+ 16_i8,
+ 127_i8
+].
+
+%---------------------------------------------------------------------------%
+:- end_module cmp_int8.
+%---------------------------------------------------------------------------%
diff --git a/tests/hard_coded/cmp_uint16.exp b/tests/hard_coded/cmp_uint16.exp
index e95ea87f3..1f6197b33 100644
--- a/tests/hard_coded/cmp_uint16.exp
+++ b/tests/hard_coded/cmp_uint16.exp
@@ -7,7 +7,7 @@
0 == 10 = false
0 == 16 = false
0 == 255 = false
-0 == 65535 = false
+0 == 32767 = false
1 == 0 = false
1 == 1 = true
1 == 2 = false
@@ -15,7 +15,7 @@
1 == 10 = false
1 == 16 = false
1 == 255 = false
-1 == 65535 = false
+1 == 32767 = false
2 == 0 = false
2 == 1 = false
2 == 2 = true
@@ -23,7 +23,7 @@
2 == 10 = false
2 == 16 = false
2 == 255 = false
-2 == 65535 = false
+2 == 32767 = false
8 == 0 = false
8 == 1 = false
8 == 2 = false
@@ -31,7 +31,7 @@
8 == 10 = false
8 == 16 = false
8 == 255 = false
-8 == 65535 = false
+8 == 32767 = false
10 == 0 = false
10 == 1 = false
10 == 2 = false
@@ -39,7 +39,7 @@
10 == 10 = true
10 == 16 = false
10 == 255 = false
-10 == 65535 = false
+10 == 32767 = false
16 == 0 = false
16 == 1 = false
16 == 2 = false
@@ -47,7 +47,7 @@
16 == 10 = false
16 == 16 = true
16 == 255 = false
-16 == 65535 = false
+16 == 32767 = false
255 == 0 = false
255 == 1 = false
255 == 2 = false
@@ -55,15 +55,15 @@
255 == 10 = false
255 == 16 = false
255 == 255 = true
-255 == 65535 = false
-65535 == 0 = false
-65535 == 1 = false
-65535 == 2 = false
-65535 == 8 = false
-65535 == 10 = false
-65535 == 16 = false
-65535 == 255 = false
-65535 == 65535 = true
+255 == 32767 = false
+32767 == 0 = false
+32767 == 1 = false
+32767 == 2 = false
+32767 == 8 = false
+32767 == 10 = false
+32767 == 16 = false
+32767 == 255 = false
+32767 == 32767 = true
*** Testing uint16.'<' ***
@@ -74,7 +74,7 @@
0 < 10 = true
0 < 16 = true
0 < 255 = true
-0 < 65535 = true
+0 < 32767 = true
1 < 0 = false
1 < 1 = false
1 < 2 = true
@@ -82,7 +82,7 @@
1 < 10 = true
1 < 16 = true
1 < 255 = true
-1 < 65535 = true
+1 < 32767 = true
2 < 0 = false
2 < 1 = false
2 < 2 = false
@@ -90,7 +90,7 @@
2 < 10 = true
2 < 16 = true
2 < 255 = true
-2 < 65535 = true
+2 < 32767 = true
8 < 0 = false
8 < 1 = false
8 < 2 = false
@@ -98,7 +98,7 @@
8 < 10 = true
8 < 16 = true
8 < 255 = true
-8 < 65535 = true
+8 < 32767 = true
10 < 0 = false
10 < 1 = false
10 < 2 = false
@@ -106,7 +106,7 @@
10 < 10 = false
10 < 16 = true
10 < 255 = true
-10 < 65535 = true
+10 < 32767 = true
16 < 0 = false
16 < 1 = false
16 < 2 = false
@@ -114,7 +114,7 @@
16 < 10 = false
16 < 16 = false
16 < 255 = true
-16 < 65535 = true
+16 < 32767 = true
255 < 0 = false
255 < 1 = false
255 < 2 = false
@@ -122,15 +122,15 @@
255 < 10 = false
255 < 16 = false
255 < 255 = false
-255 < 65535 = true
-65535 < 0 = false
-65535 < 1 = false
-65535 < 2 = false
-65535 < 8 = false
-65535 < 10 = false
-65535 < 16 = false
-65535 < 255 = false
-65535 < 65535 = false
+255 < 32767 = true
+32767 < 0 = false
+32767 < 1 = false
+32767 < 2 = false
+32767 < 8 = false
+32767 < 10 = false
+32767 < 16 = false
+32767 < 255 = false
+32767 < 32767 = false
*** Testing uint16.'=<' ***
@@ -141,7 +141,7 @@
0 =< 10 = true
0 =< 16 = true
0 =< 255 = true
-0 =< 65535 = true
+0 =< 32767 = true
1 =< 0 = false
1 =< 1 = true
1 =< 2 = true
@@ -149,7 +149,7 @@
1 =< 10 = true
1 =< 16 = true
1 =< 255 = true
-1 =< 65535 = true
+1 =< 32767 = true
2 =< 0 = false
2 =< 1 = false
2 =< 2 = true
@@ -157,7 +157,7 @@
2 =< 10 = true
2 =< 16 = true
2 =< 255 = true
-2 =< 65535 = true
+2 =< 32767 = true
8 =< 0 = false
8 =< 1 = false
8 =< 2 = false
@@ -165,7 +165,7 @@
8 =< 10 = true
8 =< 16 = true
8 =< 255 = true
-8 =< 65535 = true
+8 =< 32767 = true
10 =< 0 = false
10 =< 1 = false
10 =< 2 = false
@@ -173,7 +173,7 @@
10 =< 10 = true
10 =< 16 = true
10 =< 255 = true
-10 =< 65535 = true
+10 =< 32767 = true
16 =< 0 = false
16 =< 1 = false
16 =< 2 = false
@@ -181,7 +181,7 @@
16 =< 10 = false
16 =< 16 = true
16 =< 255 = true
-16 =< 65535 = true
+16 =< 32767 = true
255 =< 0 = false
255 =< 1 = false
255 =< 2 = false
@@ -189,15 +189,15 @@
255 =< 10 = false
255 =< 16 = false
255 =< 255 = true
-255 =< 65535 = true
-65535 =< 0 = false
-65535 =< 1 = false
-65535 =< 2 = false
-65535 =< 8 = false
-65535 =< 10 = false
-65535 =< 16 = false
-65535 =< 255 = false
-65535 =< 65535 = true
+255 =< 32767 = true
+32767 =< 0 = false
+32767 =< 1 = false
+32767 =< 2 = false
+32767 =< 8 = false
+32767 =< 10 = false
+32767 =< 16 = false
+32767 =< 255 = false
+32767 =< 32767 = true
*** Testing uint16.'>' ***
@@ -208,7 +208,7 @@
0 > 10 = false
0 > 16 = false
0 > 255 = false
-0 > 65535 = false
+0 > 32767 = false
1 > 0 = true
1 > 1 = false
1 > 2 = false
@@ -216,7 +216,7 @@
1 > 10 = false
1 > 16 = false
1 > 255 = false
-1 > 65535 = false
+1 > 32767 = false
2 > 0 = true
2 > 1 = true
2 > 2 = false
@@ -224,7 +224,7 @@
2 > 10 = false
2 > 16 = false
2 > 255 = false
-2 > 65535 = false
+2 > 32767 = false
8 > 0 = true
8 > 1 = true
8 > 2 = true
@@ -232,7 +232,7 @@
8 > 10 = false
8 > 16 = false
8 > 255 = false
-8 > 65535 = false
+8 > 32767 = false
10 > 0 = true
10 > 1 = true
10 > 2 = true
@@ -240,7 +240,7 @@
10 > 10 = false
10 > 16 = false
10 > 255 = false
-10 > 65535 = false
+10 > 32767 = false
16 > 0 = true
16 > 1 = true
16 > 2 = true
@@ -248,7 +248,7 @@
16 > 10 = true
16 > 16 = false
16 > 255 = false
-16 > 65535 = false
+16 > 32767 = false
255 > 0 = true
255 > 1 = true
255 > 2 = true
@@ -256,15 +256,15 @@
255 > 10 = true
255 > 16 = true
255 > 255 = false
-255 > 65535 = false
-65535 > 0 = true
-65535 > 1 = true
-65535 > 2 = true
-65535 > 8 = true
-65535 > 10 = true
-65535 > 16 = true
-65535 > 255 = true
-65535 > 65535 = false
+255 > 32767 = false
+32767 > 0 = true
+32767 > 1 = true
+32767 > 2 = true
+32767 > 8 = true
+32767 > 10 = true
+32767 > 16 = true
+32767 > 255 = true
+32767 > 32767 = false
*** Testing uint16.'>=' ***
@@ -275,7 +275,7 @@
0 >= 10 = false
0 >= 16 = false
0 >= 255 = false
-0 >= 65535 = false
+0 >= 32767 = false
1 >= 0 = true
1 >= 1 = true
1 >= 2 = false
@@ -283,7 +283,7 @@
1 >= 10 = false
1 >= 16 = false
1 >= 255 = false
-1 >= 65535 = false
+1 >= 32767 = false
2 >= 0 = true
2 >= 1 = true
2 >= 2 = true
@@ -291,7 +291,7 @@
2 >= 10 = false
2 >= 16 = false
2 >= 255 = false
-2 >= 65535 = false
+2 >= 32767 = false
8 >= 0 = true
8 >= 1 = true
8 >= 2 = true
@@ -299,7 +299,7 @@
8 >= 10 = false
8 >= 16 = false
8 >= 255 = false
-8 >= 65535 = false
+8 >= 32767 = false
10 >= 0 = true
10 >= 1 = true
10 >= 2 = true
@@ -307,7 +307,7 @@
10 >= 10 = true
10 >= 16 = false
10 >= 255 = false
-10 >= 65535 = false
+10 >= 32767 = false
16 >= 0 = true
16 >= 1 = true
16 >= 2 = true
@@ -315,7 +315,7 @@
16 >= 10 = true
16 >= 16 = true
16 >= 255 = false
-16 >= 65535 = false
+16 >= 32767 = false
255 >= 0 = true
255 >= 1 = true
255 >= 2 = true
@@ -323,12 +323,12 @@
255 >= 10 = true
255 >= 16 = true
255 >= 255 = true
-255 >= 65535 = false
-65535 >= 0 = true
-65535 >= 1 = true
-65535 >= 2 = true
-65535 >= 8 = true
-65535 >= 10 = true
-65535 >= 16 = true
-65535 >= 255 = true
-65535 >= 65535 = true
+255 >= 32767 = false
+32767 >= 0 = true
+32767 >= 1 = true
+32767 >= 2 = true
+32767 >= 8 = true
+32767 >= 10 = true
+32767 >= 16 = true
+32767 >= 255 = true
+32767 >= 32767 = true
diff --git a/tests/hard_coded/cmp_uint16.m b/tests/hard_coded/cmp_uint16.m
index e69de29bb..b9c44d0b4 100644
--- a/tests/hard_coded/cmp_uint16.m
+++ b/tests/hard_coded/cmp_uint16.m
@@ -0,0 +1,76 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+
+% Test comparison operations for unsigned 16-bit integers.
+
+:- module cmp_uint16.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module uint16.
+
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+ run_cmp_test(unify, "==", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint16.(<), "<", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint16.(=<), "=<", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint16.(>), ">", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint16.(>=), ">=", !IO).
+
+:- pred run_cmp_test(pred(uint16, uint16)::in(pred(in, in) is semidet),
+ string::in, io::di, io::uo) is det.
+
+run_cmp_test(CmpPred, Desc, !IO) :-
+ io.format("*** Testing uint16.'%s' ***\n\n", [s(Desc)], !IO),
+ As = numbers,
+ Bs = numbers,
+ list.foldl(run_cmp_test_2(CmpPred, Desc, Bs), As, !IO).
+
+:- pred run_cmp_test_2(pred(uint16, uint16)::in(pred(in, in) is semidet),
+ string::in, list(uint16)::in, uint16::in, io::di, io::uo) is det.
+
+run_cmp_test_2(CmpPred, Desc, Bs, A, !IO) :-
+ list.foldl(run_cmp_test_3(CmpPred, Desc, A), Bs, !IO).
+
+:- pred run_cmp_test_3(pred(uint16, uint16)::in(pred(in, in) is semidet), string::in,
+ uint16::in, uint16::in, io::di, io::uo) is det.
+
+run_cmp_test_3(CmpPred, Desc, A, B, !IO) :-
+ Result = ( if CmpPred(A, B) then "true" else "false" ),
+ io.format("%s %s %s = %s\n",
+ [s(uint16_to_string(A)), s(Desc), s(uint16_to_string(B)), s(Result)],
+ !IO).
+
+:- func numbers = list(uint16).
+
+numbers = [
+ 0_u16,
+ 1_u16,
+ 2_u16,
+ 8_u16,
+ 10_u16,
+ 16_u16,
+ 255_u16,
+ 32_767_u16
+].
+
+%---------------------------------------------------------------------------%
+:- end_module cmp_uint16.
+%---------------------------------------------------------------------------%
diff --git a/tests/hard_coded/cmp_uint32.exp b/tests/hard_coded/cmp_uint32.exp
index a633aba29..e48969cc8 100644
--- a/tests/hard_coded/cmp_uint32.exp
+++ b/tests/hard_coded/cmp_uint32.exp
@@ -4,82 +4,82 @@
0 == 1 = false
0 == 2 = false
0 == 8 = false
-0 == 10 = false
0 == 16 = false
0 == 255 = false
0 == 65535 = false
+0 == 2147483647 = false
0 == 4294967295 = false
1 == 0 = false
1 == 1 = true
1 == 2 = false
1 == 8 = false
-1 == 10 = false
1 == 16 = false
1 == 255 = false
1 == 65535 = false
+1 == 2147483647 = false
1 == 4294967295 = false
2 == 0 = false
2 == 1 = false
2 == 2 = true
2 == 8 = false
-2 == 10 = false
2 == 16 = false
2 == 255 = false
2 == 65535 = false
+2 == 2147483647 = false
2 == 4294967295 = false
8 == 0 = false
8 == 1 = false
8 == 2 = false
8 == 8 = true
-8 == 10 = false
8 == 16 = false
8 == 255 = false
8 == 65535 = false
+8 == 2147483647 = false
8 == 4294967295 = false
-10 == 0 = false
-10 == 1 = false
-10 == 2 = false
-10 == 8 = false
-10 == 10 = true
-10 == 16 = false
-10 == 255 = false
-10 == 65535 = false
-10 == 4294967295 = false
16 == 0 = false
16 == 1 = false
16 == 2 = false
16 == 8 = false
-16 == 10 = false
16 == 16 = true
16 == 255 = false
16 == 65535 = false
+16 == 2147483647 = false
16 == 4294967295 = false
255 == 0 = false
255 == 1 = false
255 == 2 = false
255 == 8 = false
-255 == 10 = false
255 == 16 = false
255 == 255 = true
255 == 65535 = false
+255 == 2147483647 = false
255 == 4294967295 = false
65535 == 0 = false
65535 == 1 = false
65535 == 2 = false
65535 == 8 = false
-65535 == 10 = false
65535 == 16 = false
65535 == 255 = false
65535 == 65535 = true
+65535 == 2147483647 = false
65535 == 4294967295 = false
+2147483647 == 0 = false
+2147483647 == 1 = false
+2147483647 == 2 = false
+2147483647 == 8 = false
+2147483647 == 16 = false
+2147483647 == 255 = false
+2147483647 == 65535 = false
+2147483647 == 2147483647 = true
+2147483647 == 4294967295 = false
4294967295 == 0 = false
4294967295 == 1 = false
4294967295 == 2 = false
4294967295 == 8 = false
-4294967295 == 10 = false
4294967295 == 16 = false
4294967295 == 255 = false
4294967295 == 65535 = false
+4294967295 == 2147483647 = false
4294967295 == 4294967295 = true
*** Testing uint32.'<' ***
@@ -88,82 +88,82 @@
0 < 1 = true
0 < 2 = true
0 < 8 = true
-0 < 10 = true
0 < 16 = true
0 < 255 = true
0 < 65535 = true
+0 < 2147483647 = true
0 < 4294967295 = true
1 < 0 = false
1 < 1 = false
1 < 2 = true
1 < 8 = true
-1 < 10 = true
1 < 16 = true
1 < 255 = true
1 < 65535 = true
+1 < 2147483647 = true
1 < 4294967295 = true
2 < 0 = false
2 < 1 = false
2 < 2 = false
2 < 8 = true
-2 < 10 = true
2 < 16 = true
2 < 255 = true
2 < 65535 = true
+2 < 2147483647 = true
2 < 4294967295 = true
8 < 0 = false
8 < 1 = false
8 < 2 = false
8 < 8 = false
-8 < 10 = true
8 < 16 = true
8 < 255 = true
8 < 65535 = true
+8 < 2147483647 = true
8 < 4294967295 = true
-10 < 0 = false
-10 < 1 = false
-10 < 2 = false
-10 < 8 = false
-10 < 10 = false
-10 < 16 = true
-10 < 255 = true
-10 < 65535 = true
-10 < 4294967295 = true
16 < 0 = false
16 < 1 = false
16 < 2 = false
16 < 8 = false
-16 < 10 = false
16 < 16 = false
16 < 255 = true
16 < 65535 = true
+16 < 2147483647 = true
16 < 4294967295 = true
255 < 0 = false
255 < 1 = false
255 < 2 = false
255 < 8 = false
-255 < 10 = false
255 < 16 = false
255 < 255 = false
255 < 65535 = true
+255 < 2147483647 = true
255 < 4294967295 = true
65535 < 0 = false
65535 < 1 = false
65535 < 2 = false
65535 < 8 = false
-65535 < 10 = false
65535 < 16 = false
65535 < 255 = false
65535 < 65535 = false
+65535 < 2147483647 = true
65535 < 4294967295 = true
+2147483647 < 0 = false
+2147483647 < 1 = false
+2147483647 < 2 = false
+2147483647 < 8 = false
+2147483647 < 16 = false
+2147483647 < 255 = false
+2147483647 < 65535 = false
+2147483647 < 2147483647 = false
+2147483647 < 4294967295 = true
4294967295 < 0 = false
4294967295 < 1 = false
4294967295 < 2 = false
4294967295 < 8 = false
-4294967295 < 10 = false
4294967295 < 16 = false
4294967295 < 255 = false
4294967295 < 65535 = false
+4294967295 < 2147483647 = false
4294967295 < 4294967295 = false
*** Testing uint32.'=<' ***
@@ -172,82 +172,82 @@
0 =< 1 = true
0 =< 2 = true
0 =< 8 = true
-0 =< 10 = true
0 =< 16 = true
0 =< 255 = true
0 =< 65535 = true
+0 =< 2147483647 = true
0 =< 4294967295 = true
1 =< 0 = false
1 =< 1 = true
1 =< 2 = true
1 =< 8 = true
-1 =< 10 = true
1 =< 16 = true
1 =< 255 = true
1 =< 65535 = true
+1 =< 2147483647 = true
1 =< 4294967295 = true
2 =< 0 = false
2 =< 1 = false
2 =< 2 = true
2 =< 8 = true
-2 =< 10 = true
2 =< 16 = true
2 =< 255 = true
2 =< 65535 = true
+2 =< 2147483647 = true
2 =< 4294967295 = true
8 =< 0 = false
8 =< 1 = false
8 =< 2 = false
8 =< 8 = true
-8 =< 10 = true
8 =< 16 = true
8 =< 255 = true
8 =< 65535 = true
+8 =< 2147483647 = true
8 =< 4294967295 = true
-10 =< 0 = false
-10 =< 1 = false
-10 =< 2 = false
-10 =< 8 = false
-10 =< 10 = true
-10 =< 16 = true
-10 =< 255 = true
-10 =< 65535 = true
-10 =< 4294967295 = true
16 =< 0 = false
16 =< 1 = false
16 =< 2 = false
16 =< 8 = false
-16 =< 10 = false
16 =< 16 = true
16 =< 255 = true
16 =< 65535 = true
+16 =< 2147483647 = true
16 =< 4294967295 = true
255 =< 0 = false
255 =< 1 = false
255 =< 2 = false
255 =< 8 = false
-255 =< 10 = false
255 =< 16 = false
255 =< 255 = true
255 =< 65535 = true
+255 =< 2147483647 = true
255 =< 4294967295 = true
65535 =< 0 = false
65535 =< 1 = false
65535 =< 2 = false
65535 =< 8 = false
-65535 =< 10 = false
65535 =< 16 = false
65535 =< 255 = false
65535 =< 65535 = true
+65535 =< 2147483647 = true
65535 =< 4294967295 = true
+2147483647 =< 0 = false
+2147483647 =< 1 = false
+2147483647 =< 2 = false
+2147483647 =< 8 = false
+2147483647 =< 16 = false
+2147483647 =< 255 = false
+2147483647 =< 65535 = false
+2147483647 =< 2147483647 = true
+2147483647 =< 4294967295 = true
4294967295 =< 0 = false
4294967295 =< 1 = false
4294967295 =< 2 = false
4294967295 =< 8 = false
-4294967295 =< 10 = false
4294967295 =< 16 = false
4294967295 =< 255 = false
4294967295 =< 65535 = false
+4294967295 =< 2147483647 = false
4294967295 =< 4294967295 = true
*** Testing uint32.'>' ***
@@ -256,82 +256,82 @@
0 > 1 = false
0 > 2 = false
0 > 8 = false
-0 > 10 = false
0 > 16 = false
0 > 255 = false
0 > 65535 = false
+0 > 2147483647 = false
0 > 4294967295 = false
1 > 0 = true
1 > 1 = false
1 > 2 = false
1 > 8 = false
-1 > 10 = false
1 > 16 = false
1 > 255 = false
1 > 65535 = false
+1 > 2147483647 = false
1 > 4294967295 = false
2 > 0 = true
2 > 1 = true
2 > 2 = false
2 > 8 = false
-2 > 10 = false
2 > 16 = false
2 > 255 = false
2 > 65535 = false
+2 > 2147483647 = false
2 > 4294967295 = false
8 > 0 = true
8 > 1 = true
8 > 2 = true
8 > 8 = false
-8 > 10 = false
8 > 16 = false
8 > 255 = false
8 > 65535 = false
+8 > 2147483647 = false
8 > 4294967295 = false
-10 > 0 = true
-10 > 1 = true
-10 > 2 = true
-10 > 8 = true
-10 > 10 = false
-10 > 16 = false
-10 > 255 = false
-10 > 65535 = false
-10 > 4294967295 = false
16 > 0 = true
16 > 1 = true
16 > 2 = true
16 > 8 = true
-16 > 10 = true
16 > 16 = false
16 > 255 = false
16 > 65535 = false
+16 > 2147483647 = false
16 > 4294967295 = false
255 > 0 = true
255 > 1 = true
255 > 2 = true
255 > 8 = true
-255 > 10 = true
255 > 16 = true
255 > 255 = false
255 > 65535 = false
+255 > 2147483647 = false
255 > 4294967295 = false
65535 > 0 = true
65535 > 1 = true
65535 > 2 = true
65535 > 8 = true
-65535 > 10 = true
65535 > 16 = true
65535 > 255 = true
65535 > 65535 = false
+65535 > 2147483647 = false
65535 > 4294967295 = false
+2147483647 > 0 = true
+2147483647 > 1 = true
+2147483647 > 2 = true
+2147483647 > 8 = true
+2147483647 > 16 = true
+2147483647 > 255 = true
+2147483647 > 65535 = true
+2147483647 > 2147483647 = false
+2147483647 > 4294967295 = false
4294967295 > 0 = true
4294967295 > 1 = true
4294967295 > 2 = true
4294967295 > 8 = true
-4294967295 > 10 = true
4294967295 > 16 = true
4294967295 > 255 = true
4294967295 > 65535 = true
+4294967295 > 2147483647 = true
4294967295 > 4294967295 = false
*** Testing uint32.'>=' ***
@@ -340,80 +340,80 @@
0 >= 1 = false
0 >= 2 = false
0 >= 8 = false
-0 >= 10 = false
0 >= 16 = false
0 >= 255 = false
0 >= 65535 = false
+0 >= 2147483647 = false
0 >= 4294967295 = false
1 >= 0 = true
1 >= 1 = true
1 >= 2 = false
1 >= 8 = false
-1 >= 10 = false
1 >= 16 = false
1 >= 255 = false
1 >= 65535 = false
+1 >= 2147483647 = false
1 >= 4294967295 = false
2 >= 0 = true
2 >= 1 = true
2 >= 2 = true
2 >= 8 = false
-2 >= 10 = false
2 >= 16 = false
2 >= 255 = false
2 >= 65535 = false
+2 >= 2147483647 = false
2 >= 4294967295 = false
8 >= 0 = true
8 >= 1 = true
8 >= 2 = true
8 >= 8 = true
-8 >= 10 = false
8 >= 16 = false
8 >= 255 = false
8 >= 65535 = false
+8 >= 2147483647 = false
8 >= 4294967295 = false
-10 >= 0 = true
-10 >= 1 = true
-10 >= 2 = true
-10 >= 8 = true
-10 >= 10 = true
-10 >= 16 = false
-10 >= 255 = false
-10 >= 65535 = false
-10 >= 4294967295 = false
16 >= 0 = true
16 >= 1 = true
16 >= 2 = true
16 >= 8 = true
-16 >= 10 = true
16 >= 16 = true
16 >= 255 = false
16 >= 65535 = false
+16 >= 2147483647 = false
16 >= 4294967295 = false
255 >= 0 = true
255 >= 1 = true
255 >= 2 = true
255 >= 8 = true
-255 >= 10 = true
255 >= 16 = true
255 >= 255 = true
255 >= 65535 = false
+255 >= 2147483647 = false
255 >= 4294967295 = false
65535 >= 0 = true
65535 >= 1 = true
65535 >= 2 = true
65535 >= 8 = true
-65535 >= 10 = true
65535 >= 16 = true
65535 >= 255 = true
65535 >= 65535 = true
+65535 >= 2147483647 = false
65535 >= 4294967295 = false
+2147483647 >= 0 = true
+2147483647 >= 1 = true
+2147483647 >= 2 = true
+2147483647 >= 8 = true
+2147483647 >= 16 = true
+2147483647 >= 255 = true
+2147483647 >= 65535 = true
+2147483647 >= 2147483647 = true
+2147483647 >= 4294967295 = false
4294967295 >= 0 = true
4294967295 >= 1 = true
4294967295 >= 2 = true
4294967295 >= 8 = true
-4294967295 >= 10 = true
4294967295 >= 16 = true
4294967295 >= 255 = true
4294967295 >= 65535 = true
+4294967295 >= 2147483647 = true
4294967295 >= 4294967295 = true
diff --git a/tests/hard_coded/cmp_uint32.m b/tests/hard_coded/cmp_uint32.m
index e69de29bb..b846aca61 100644
--- a/tests/hard_coded/cmp_uint32.m
+++ b/tests/hard_coded/cmp_uint32.m
@@ -0,0 +1,77 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+
+% Test comparison operations for unsigned 32-bit integers.
+
+:- module cmp_uint32.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module uint32.
+
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+ run_cmp_test(unify, "==", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint32.(<), "<", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint32.(=<), "=<", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint32.(>), ">", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint32.(>=), ">=", !IO).
+
+:- pred run_cmp_test(pred(uint32, uint32)::in(pred(in, in) is semidet),
+ string::in, io::di, io::uo) is det.
+
+run_cmp_test(CmpPred, Desc, !IO) :-
+ io.format("*** Testing uint32.'%s' ***\n\n", [s(Desc)], !IO),
+ As = numbers,
+ Bs = numbers,
+ list.foldl(run_cmp_test_2(CmpPred, Desc, Bs), As, !IO).
+
+:- pred run_cmp_test_2(pred(uint32, uint32)::in(pred(in, in) is semidet),
+ string::in, list(uint32)::in, uint32::in, io::di, io::uo) is det.
+
+run_cmp_test_2(CmpPred, Desc, Bs, A, !IO) :-
+ list.foldl(run_cmp_test_3(CmpPred, Desc, A), Bs, !IO).
+
+:- pred run_cmp_test_3(pred(uint32, uint32)::in(pred(in, in) is semidet), string::in,
+ uint32::in, uint32::in, io::di, io::uo) is det.
+
+run_cmp_test_3(CmpPred, Desc, A, B, !IO) :-
+ Result = ( if CmpPred(A, B) then "true" else "false" ),
+ io.format("%s %s %s = %s\n",
+ [s(uint32_to_string(A)), s(Desc), s(uint32_to_string(B)), s(Result)],
+ !IO).
+
+:- func numbers = list(uint32).
+
+numbers = [
+ 0_u32,
+ 1_u32,
+ 2_u32,
+ 8_u32,
+ 16_u32,
+ 255_u32,
+ 65_535_u32,
+ 2_147_483_647_u32,
+ 4_294_967_295_u32
+].
+
+%---------------------------------------------------------------------------%
+:- end_module cmp_uint32.
+%---------------------------------------------------------------------------%
diff --git a/tests/hard_coded/cmp_uint8.exp b/tests/hard_coded/cmp_uint8.exp
index 4dbc99b82..f2e2af98b 100644
--- a/tests/hard_coded/cmp_uint8.exp
+++ b/tests/hard_coded/cmp_uint8.exp
@@ -6,6 +6,7 @@
0 == 8 = false
0 == 10 = false
0 == 16 = false
+0 == 127 = false
0 == 255 = false
1 == 0 = false
1 == 1 = true
@@ -13,6 +14,7 @@
1 == 8 = false
1 == 10 = false
1 == 16 = false
+1 == 127 = false
1 == 255 = false
2 == 0 = false
2 == 1 = false
@@ -20,6 +22,7 @@
2 == 8 = false
2 == 10 = false
2 == 16 = false
+2 == 127 = false
2 == 255 = false
8 == 0 = false
8 == 1 = false
@@ -27,6 +30,7 @@
8 == 8 = true
8 == 10 = false
8 == 16 = false
+8 == 127 = false
8 == 255 = false
10 == 0 = false
10 == 1 = false
@@ -34,6 +38,7 @@
10 == 8 = false
10 == 10 = true
10 == 16 = false
+10 == 127 = false
10 == 255 = false
16 == 0 = false
16 == 1 = false
@@ -41,13 +46,23 @@
16 == 8 = false
16 == 10 = false
16 == 16 = true
+16 == 127 = false
16 == 255 = false
+127 == 0 = false
+127 == 1 = false
+127 == 2 = false
+127 == 8 = false
+127 == 10 = false
+127 == 16 = false
+127 == 127 = true
+127 == 255 = false
255 == 0 = false
255 == 1 = false
255 == 2 = false
255 == 8 = false
255 == 10 = false
255 == 16 = false
+255 == 127 = false
255 == 255 = true
*** Testing uint8.'<' ***
@@ -58,6 +73,7 @@
0 < 8 = true
0 < 10 = true
0 < 16 = true
+0 < 127 = true
0 < 255 = true
1 < 0 = false
1 < 1 = false
@@ -65,6 +81,7 @@
1 < 8 = true
1 < 10 = true
1 < 16 = true
+1 < 127 = true
1 < 255 = true
2 < 0 = false
2 < 1 = false
@@ -72,6 +89,7 @@
2 < 8 = true
2 < 10 = true
2 < 16 = true
+2 < 127 = true
2 < 255 = true
8 < 0 = false
8 < 1 = false
@@ -79,6 +97,7 @@
8 < 8 = false
8 < 10 = true
8 < 16 = true
+8 < 127 = true
8 < 255 = true
10 < 0 = false
10 < 1 = false
@@ -86,6 +105,7 @@
10 < 8 = false
10 < 10 = false
10 < 16 = true
+10 < 127 = true
10 < 255 = true
16 < 0 = false
16 < 1 = false
@@ -93,13 +113,23 @@
16 < 8 = false
16 < 10 = false
16 < 16 = false
+16 < 127 = true
16 < 255 = true
+127 < 0 = false
+127 < 1 = false
+127 < 2 = false
+127 < 8 = false
+127 < 10 = false
+127 < 16 = false
+127 < 127 = false
+127 < 255 = true
255 < 0 = false
255 < 1 = false
255 < 2 = false
255 < 8 = false
255 < 10 = false
255 < 16 = false
+255 < 127 = false
255 < 255 = false
*** Testing uint8.'=<' ***
@@ -110,6 +140,7 @@
0 =< 8 = true
0 =< 10 = true
0 =< 16 = true
+0 =< 127 = true
0 =< 255 = true
1 =< 0 = false
1 =< 1 = true
@@ -117,6 +148,7 @@
1 =< 8 = true
1 =< 10 = true
1 =< 16 = true
+1 =< 127 = true
1 =< 255 = true
2 =< 0 = false
2 =< 1 = false
@@ -124,6 +156,7 @@
2 =< 8 = true
2 =< 10 = true
2 =< 16 = true
+2 =< 127 = true
2 =< 255 = true
8 =< 0 = false
8 =< 1 = false
@@ -131,6 +164,7 @@
8 =< 8 = true
8 =< 10 = true
8 =< 16 = true
+8 =< 127 = true
8 =< 255 = true
10 =< 0 = false
10 =< 1 = false
@@ -138,6 +172,7 @@
10 =< 8 = false
10 =< 10 = true
10 =< 16 = true
+10 =< 127 = true
10 =< 255 = true
16 =< 0 = false
16 =< 1 = false
@@ -145,13 +180,23 @@
16 =< 8 = false
16 =< 10 = false
16 =< 16 = true
+16 =< 127 = true
16 =< 255 = true
+127 =< 0 = false
+127 =< 1 = false
+127 =< 2 = false
+127 =< 8 = false
+127 =< 10 = false
+127 =< 16 = false
+127 =< 127 = true
+127 =< 255 = true
255 =< 0 = false
255 =< 1 = false
255 =< 2 = false
255 =< 8 = false
255 =< 10 = false
255 =< 16 = false
+255 =< 127 = false
255 =< 255 = true
*** Testing uint8.'>' ***
@@ -162,6 +207,7 @@
0 > 8 = false
0 > 10 = false
0 > 16 = false
+0 > 127 = false
0 > 255 = false
1 > 0 = true
1 > 1 = false
@@ -169,6 +215,7 @@
1 > 8 = false
1 > 10 = false
1 > 16 = false
+1 > 127 = false
1 > 255 = false
2 > 0 = true
2 > 1 = true
@@ -176,6 +223,7 @@
2 > 8 = false
2 > 10 = false
2 > 16 = false
+2 > 127 = false
2 > 255 = false
8 > 0 = true
8 > 1 = true
@@ -183,6 +231,7 @@
8 > 8 = false
8 > 10 = false
8 > 16 = false
+8 > 127 = false
8 > 255 = false
10 > 0 = true
10 > 1 = true
@@ -190,6 +239,7 @@
10 > 8 = true
10 > 10 = false
10 > 16 = false
+10 > 127 = false
10 > 255 = false
16 > 0 = true
16 > 1 = true
@@ -197,13 +247,23 @@
16 > 8 = true
16 > 10 = true
16 > 16 = false
+16 > 127 = false
16 > 255 = false
+127 > 0 = true
+127 > 1 = true
+127 > 2 = true
+127 > 8 = true
+127 > 10 = true
+127 > 16 = true
+127 > 127 = false
+127 > 255 = false
255 > 0 = true
255 > 1 = true
255 > 2 = true
255 > 8 = true
255 > 10 = true
255 > 16 = true
+255 > 127 = true
255 > 255 = false
*** Testing uint8.'>=' ***
@@ -214,6 +274,7 @@
0 >= 8 = false
0 >= 10 = false
0 >= 16 = false
+0 >= 127 = false
0 >= 255 = false
1 >= 0 = true
1 >= 1 = true
@@ -221,6 +282,7 @@
1 >= 8 = false
1 >= 10 = false
1 >= 16 = false
+1 >= 127 = false
1 >= 255 = false
2 >= 0 = true
2 >= 1 = true
@@ -228,6 +290,7 @@
2 >= 8 = false
2 >= 10 = false
2 >= 16 = false
+2 >= 127 = false
2 >= 255 = false
8 >= 0 = true
8 >= 1 = true
@@ -235,6 +298,7 @@
8 >= 8 = true
8 >= 10 = false
8 >= 16 = false
+8 >= 127 = false
8 >= 255 = false
10 >= 0 = true
10 >= 1 = true
@@ -242,6 +306,7 @@
10 >= 8 = true
10 >= 10 = true
10 >= 16 = false
+10 >= 127 = false
10 >= 255 = false
16 >= 0 = true
16 >= 1 = true
@@ -249,11 +314,21 @@
16 >= 8 = true
16 >= 10 = true
16 >= 16 = true
+16 >= 127 = false
16 >= 255 = false
+127 >= 0 = true
+127 >= 1 = true
+127 >= 2 = true
+127 >= 8 = true
+127 >= 10 = true
+127 >= 16 = true
+127 >= 127 = true
+127 >= 255 = false
255 >= 0 = true
255 >= 1 = true
255 >= 2 = true
255 >= 8 = true
255 >= 10 = true
255 >= 16 = true
+255 >= 127 = true
255 >= 255 = true
diff --git a/tests/hard_coded/cmp_uint8.m b/tests/hard_coded/cmp_uint8.m
index e69de29bb..398eda0ed 100644
--- a/tests/hard_coded/cmp_uint8.m
+++ b/tests/hard_coded/cmp_uint8.m
@@ -0,0 +1,76 @@
+%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et wm=0 tw=0
+%---------------------------------------------------------------------------%
+
+% Test comparison operations for unsigned 8-bit integers.
+
+:- module cmp_uint8.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is det.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module uint8.
+
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+ run_cmp_test(unify, "==", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint8.(<), "<", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint8.(=<), "=<", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint8.(>), ">", !IO),
+ io.nl(!IO),
+ run_cmp_test(uint8.(>=), ">=", !IO).
+
+:- pred run_cmp_test(pred(uint8, uint8)::in(pred(in, in) is semidet),
+ string::in, io::di, io::uo) is det.
+
+run_cmp_test(CmpPred, Desc, !IO) :-
+ io.format("*** Testing uint8.'%s' ***\n\n", [s(Desc)], !IO),
+ As = numbers,
+ Bs = numbers,
+ list.foldl(run_cmp_test_2(CmpPred, Desc, Bs), As, !IO).
+
+:- pred run_cmp_test_2(pred(uint8, uint8)::in(pred(in, in) is semidet),
+ string::in, list(uint8)::in, uint8::in, io::di, io::uo) is det.
+
+run_cmp_test_2(CmpPred, Desc, Bs, A, !IO) :-
+ list.foldl(run_cmp_test_3(CmpPred, Desc, A), Bs, !IO).
+
+:- pred run_cmp_test_3(pred(uint8, uint8)::in(pred(in, in) is semidet), string::in,
+ uint8::in, uint8::in, io::di, io::uo) is det.
+
+run_cmp_test_3(CmpPred, Desc, A, B, !IO) :-
+ Result = ( if CmpPred(A, B) then "true" else "false" ),
+ io.format("%s %s %s = %s\n",
+ [s(uint8_to_string(A)), s(Desc), s(uint8_to_string(B)), s(Result)],
+ !IO).
+
+:- func numbers = list(uint8).
+
+numbers = [
+ 0_u8,
+ 1_u8,
+ 2_u8,
+ 8_u8,
+ 10_u8,
+ 16_u8,
+ 127_u8,
+ 255_u8
+].
+
+%---------------------------------------------------------------------------%
+:- end_module cmp_uint8.
+%---------------------------------------------------------------------------%
More information about the reviews
mailing list