diff options
author | David Mitchell <davem@iabyn.com> | 2011-03-26 23:48:04 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2011-03-26 23:48:04 +0000 |
commit | e76f5e873f85fc85f1c899914749a50feed6f801 (patch) | |
tree | d1ca8dd32422caf4902a16552a631502ffe75893 /t/op/cmp.t | |
parent | 976bd1ee7053935efaef1e933f9101527e753e0f (diff) | |
download | perl-e76f5e873f85fc85f1c899914749a50feed6f801.tar.gz |
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.
Diffstat (limited to 't/op/cmp.t')
-rw-r--r-- | t/op/cmp.t | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/t/op/cmp.t b/t/op/cmp.t index d811bae872..0fbca5fc5f 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; |