[m-rev.] diff: fix Solaris NaN test failures

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jan 29 23:32:40 AEDT 2003


Estimated hours taken: 0.5
Branches: main

tests/general/string_format_special_floats.m:
tests/general/string_format_special_floats.exp:
	Allow `-NaN' as valid output for the NaN tests.
	This is not really valid output IMHO, but that's
	what the Solaris 2.7 C library printf() outputs,
	and it's not useful to report this as a failure in
	the Mercury test suite.

	Also, split up the tests for +Inf and -Inf,
	so that the test case checks that infinities
	are formatted with the correct sign.

Workspace: /home/ceres/fjh/mercury
Index: tests/general/string_format_special_floats.exp
===================================================================
RCS file: /home/mercury1/repository/tests/general/string_format_special_floats.exp,v
retrieving revision 1.1
diff -u -d -r1.1 string_format_special_floats.exp
--- tests/general/string_format_special_floats.exp	21 Nov 2002 14:27:09 -0000	1.1
+++ tests/general/string_format_special_floats.exp	29 Jan 2003 11:29:48 -0000
@@ -1,9 +1,10 @@
-Infinity:
-                  %e: success
+Plus Infinity:
                   %e: success
                   %f: success
-                  %f: success
                   %g: success
+Minus Infinity:
+                  %e: success
+                  %f: success
                   %g: success
 Not a number:
                   %e: success
Index: tests/general/string_format_special_floats.m
===================================================================
RCS file: /home/mercury1/repository/tests/general/string_format_special_floats.m,v
retrieving revision 1.1
diff -u -d -r1.1 string_format_special_floats.m
--- tests/general/string_format_special_floats.m	21 Nov 2002 14:27:10 -0000	1.1
+++ tests/general/string_format_special_floats.m	29 Jan 2003 11:29:12 -0000
@@ -20,8 +20,11 @@
 
 main -->
 	{ Inf = (max+max) },
-	io__write_string("Infinity:\n"),
-	list__foldl(test_floats(is_infinity, [Inf, -Inf]), ["%e", "%f", "%g"]),
+	io__write_string("Plus Infinity:\n"),
+	list__foldl(test_floats(is_plus_infinity, [Inf]), ["%e", "%f", "%g"]),
+	io__write_string("Minus Infinity:\n"),
+	list__foldl(test_floats(is_minus_infinity, [-Inf]),
+		["%e", "%f", "%g"]),
 	io__write_string("Not a number:\n"),
 	list__foldl(test_floats(is_nan, [0.0 * Inf]), ["%e", "%f", "%g"]).
 
@@ -44,13 +47,19 @@
 		io__write_string("failure '" ++ FloatString ++ "'\n")
 	).
 
-:- pred is_infinity(string::in) is semidet.
+:- pred is_plus_infinity(string::in) is semidet.
 
-is_infinity(String) :-
+is_plus_infinity(String) :-
 	LowerCaseString = string__to_lower(String),
 	( LowerCaseString = "infinity"
 	; LowerCaseString = "inf"
-	; LowerCaseString = "-infinity"
+	).
+
+:- pred is_minus_infinity(string::in) is semidet.
+
+is_minus_infinity(String) :-
+	LowerCaseString = string__to_lower(String),
+	( LowerCaseString = "-infinity"
 	; LowerCaseString = "-inf"
 	).
 
@@ -58,7 +67,15 @@
 
 is_nan(String) :-
 	LowerCaseString = string__to_lower(String),
-	LowerCaseString = "nan".
+	( LowerCaseString = "nan"
+	% XXX Actually, it makes no sense to put a minus sign on a NaN,
+	%     since NaNs aren't signed.  However, the printf() function in
+	%     some C libraries (in particular, the one for Solaris 2.7)
+	%     do that.  Arguably that's a bug, but we can't do much about
+	%     bugs in the Solaris C library, so we don't want to report a
+	%     test case failure for that.  Hence we allow -NaN here.
+	; LowerCaseString = "-nan"
+	).
 
 %------------------------------------------------------------------------------%
 %------------------------------------------------------------------------------%

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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