From e76f5e873f85fc85f1c899914749a50feed6f801 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Sat, 26 Mar 2011 23:48:04 +0000 Subject: [PATCH] op/cmp.t: fix failing tests under -ffast-math Apparently if you compile using gcc's -ffast-math option, NaNs start matching other things. So skip the NaN tests. --- t/op/cmp.t | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/t/op/cmp.t b/t/op/cmp.t index d811bae..0fbca5f 100644 --- a/t/op/cmp.t +++ b/t/op/cmp.t @@ -52,10 +52,24 @@ foreach ("\x{1F4A9}", chr(163), 'N') { $expect = 7 * ($#FOO+2) * ($#FOO+1) + 6 * @raw + 6 * @utf8; print "1..$expect\n"; +my $bad_NaN = 0; + +{ + # gcc's -ffast-math option may stop NaNs working correctly + use Config; + my $ccflags = $Config{ccflags} // ''; + $bad_NaN = 1 if $ccflags =~ /-ffast-math\b/; +} + sub nok ($$$$$$$$) { my ($test, $left, $threeway, $right, $result, $i, $j, $boolean) = @_; $result = defined $result ? "'$result'" : 'undef'; - print "not ok $test # ($left $threeway $right) gives: $result \$i=$i \$j=$j, $boolean disagrees\n"; + if ($bad_NaN && ($left eq 'NaN' || $right eq 'NaN')) { + print "ok $test # skipping failed NaN test under -ffast-math\n"; + } + else { + print "not ok $test # ($left $threeway $right) gives: $result \$i=$i \$j=$j, $boolean disagrees\n"; + } } my $ok = 0; -- 1.8.3.1