[m-rev.] diff: changes to integer module

Julien Fischer juliensf at cs.mu.OZ.AU
Fri Nov 5 18:10:14 AEDT 2004


On Fri, 5 Nov 2004, Julien Fischer wrote:

>
> Estimated hours taken: 1
> Branches: main
>
...
>
> tests/hard_coded/integer_test.m:
> 	Test integer.det_from_string.
> 	Replace instances of `:' as the module qualifier.
> 	Include integer.one/0 and integer.zero/0 in some
> 	of the tests.

The diff for integer_test.m should have been this, not whatever
I posted before.

Index: integer_test.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/integer_test.m,v
retrieving revision 1.2
diff -u -r1.2 integer_test.m
--- integer_test.m	26 May 2003 09:01:07 -0000	1.2
+++ integer_test.m	5 Nov 2004 07:07:19 -0000
@@ -11,14 +11,10 @@
 :- import_module integer, string, list, int, require.

 main -->
-	{
-		X = integer:from_string("1234567890987654321"),
-		Y = integer:from_string(
-			"98765432101234567890123400000009999111"),
-		Z = integer(200)
-	;
-		error("integer_test:main: internal error in test")
-	},
+	{ X = integer.det_from_string("1234567890987654321") },
+	{ Y = integer.det_from_string(
+		"98765432101234567890123400000009999111") },
+	{ Z = integer(200) },
 	test(X, Y, Z).

 :- pred test(integer, integer, integer, io__state, io__state).
@@ -31,7 +27,7 @@
 		Minus = X - Y,
 		Div = Y // X,
 		Rem = Y rem X,
-		integer:pow(X,Z,Pow),
+		Pow = integer.pow(X, Z),
 		fac(Z,Fac)
 	},
 	write_message("X: ", X),
@@ -45,52 +41,51 @@
 	write_message("fac(Z): ", Fac),
 	write_message("pow(X,Z): ", Pow),
 	{ X0 = integer(100000), X1 = integer(3) },
-	write_integer(X0), io:write_string(" div mod "),
-		write_integer(X1), io:write_string(" = "),
-		write_integer(X0 div X1), io:write_string(" "),
-		write_integer(X0 mod X1), io:nl,
-	write_integer(-X0), io:write_string(" div mod "),
-		write_integer(X1), io:write_string(" = "),
-		write_integer(X0 div -X1), io:write_string(" "),
-		write_integer(X0 mod -X1), io:nl,
-	write_integer(X0), io:write_string(" div mod "),
-		write_integer(-X1), io:write_string(" = "),
-		write_integer(-X0 div X1), io:write_string(" "),
-		write_integer(-X0 mod X1), io:nl,
-	write_integer(-X0), io:write_string(" div mod "),
-		write_integer(-X1), io:write_string(" = "),
-		write_integer(-X0 div -X1), io:write_string(" "),
-		write_integer(-X0 mod -X1), io:nl,
-	write_integer(X0), io:write_string(" // rem "),
-		write_integer(X1), io:write_string(" = "),
-		write_integer(X0 // X1), io:write_string(" "),
-		write_integer(X0 rem X1), io:nl,
-	write_integer(-X0), io:write_string(" // rem "),
-		write_integer(X1), io:write_string(" = "),
-		write_integer(X0 // -X1), io:write_string(" "),
-		write_integer(X0 rem -X1), io:nl,
-	write_integer(X0), io:write_string(" // rem "),
-		write_integer(-X1), io:write_string(" = "),
-		write_integer(-X0 // X1), io:write_string(" "),
-		write_integer(-X0 rem X1), io:nl,
-	write_integer(-X0), io:write_string(" // rem "),
-		write_integer(-X1), io:write_string(" = "),
-		write_integer(-X0 // -X1), io:write_string(" "),
-		write_integer(-X0 rem -X1), io:nl,
-	{ int:min_int(Minint) },
+	write_integer(X0), io.write_string(" div mod "),
+		write_integer(X1), io.write_string(" = "),
+		write_integer(X0 div X1), io.write_string(" "),
+		write_integer(X0 mod X1), io.nl,
+	write_integer(-X0), io.write_string(" div mod "),
+		write_integer(X1), io.write_string(" = "),
+		write_integer(X0 div -X1), io.write_string(" "),
+		write_integer(X0 mod -X1), io.nl,
+	write_integer(X0), io.write_string(" div mod "),
+		write_integer(-X1), io.write_string(" = "),
+		write_integer(-X0 div X1), io.write_string(" "),
+		write_integer(-X0 mod X1), io.nl,
+	write_integer(-X0), io.write_string(" div mod "),
+		write_integer(-X1), io.write_string(" = "),
+		write_integer(-X0 div -X1), io.write_string(" "),
+		write_integer(-X0 mod -X1), io.nl,
+	write_integer(X0), io.write_string(" // rem "),
+		write_integer(X1), io.write_string(" = "),
+		write_integer(X0 // X1), io.write_string(" "),
+		write_integer(X0 rem X1), io.nl,
+	write_integer(-X0), io.write_string(" // rem "),
+		write_integer(X1), io.write_string(" = "),
+		write_integer(X0 // -X1), io.write_string(" "),
+		write_integer(X0 rem -X1), io.nl,
+	write_integer(X0), io.write_string(" // rem "),
+		write_integer(-X1), io.write_string(" = "),
+		write_integer(-X0 // X1), io.write_string(" "),
+		write_integer(-X0 rem X1), io.nl,
+	write_integer(-X0), io.write_string(" // rem "),
+		write_integer(-X1), io.write_string(" = "),
+		write_integer(-X0 // -X1), io.write_string(" "),
+		write_integer(-X0 rem -X1), io.nl,
+	{ int.min_int(Minint) },
 		( { integer(Minint) < integer(0) } ->
-			io:write_string("integer(min_int) ok\n")
+			io.write_string("integer(min_int) ok\n")
 		;
-			io:write_string("integer(min_int) failed\n")
+			io.write_string("integer(min_int) failed\n")
 		).

-
 :- pred write_message(string, integer, io__state, io__state).
 :- mode write_message(in, in, di, uo) is det.

 write_message(String, Int) -->
 	io__write_string(String),
-	{ Str = integer:to_string(Int) },
+	{ Str = integer.to_string(Int) },
 	io__write_string(Str),
 	io__nl.

@@ -98,17 +93,17 @@
 :- mode fac(in, out) is det.

 fac(X,F) :-
-	( X =< integer(0) ->
-		F = integer(1)
+	( X =< integer.zero ->
+		F = integer.one
 	;
-		fac(X-integer(1),F1),
+		fac(X - integer.one,F1),
 		F = F1 * X
 	).

-:- pred write_integer(integer, io:state, io:state).
+:- pred write_integer(integer, io.state, io.state).
 :- mode write_integer(in, di, uo) is det.
 write_integer(X) -->
-	{ S = integer:to_string(X) },
-	io:write_string(S).
+	{ S = integer.to_string(X) },
+	io.write_string(S).


--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list