diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-05 17:56:39 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-05 17:56:39 -0700 |
commit | c57c4f8c6227cff8ff9c1392428f97f036a34f2c (patch) | |
tree | b8f402d5be5470900dbb1b1066167f2b4174bd33 /test | |
parent | f09aaa3b311d3fc78aa9611f1213e6616df65e64 (diff) | |
parent | 497b0cb09a750fe05cf6c7c1cae2e3b960772ec4 (diff) | |
download | scala-c57c4f8c6227cff8ff9c1392428f97f036a34f2c.tar.gz scala-c57c4f8c6227cff8ff9c1392428f97f036a34f2c.tar.bz2 scala-c57c4f8c6227cff8ff9c1392428f97f036a34f2c.zip |
Merge pull request #2352 from soc/nan-tests
Add float version of the double NaN tests
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/blame_eye_triple_eee-double.check (renamed from test/files/run/blame_eye_triple_eee.check) | 0 | ||||
-rw-r--r-- | test/files/run/blame_eye_triple_eee-double.flags (renamed from test/files/run/blame_eye_triple_eee.flags) | 0 | ||||
-rw-r--r-- | test/files/run/blame_eye_triple_eee-double.scala (renamed from test/files/run/blame_eye_triple_eee.scala) | 0 | ||||
-rw-r--r-- | test/files/run/blame_eye_triple_eee-float.check | 9 | ||||
-rw-r--r-- | test/files/run/blame_eye_triple_eee-float.flags | 1 | ||||
-rw-r--r-- | test/files/run/blame_eye_triple_eee-float.scala | 61 |
6 files changed, 71 insertions, 0 deletions
diff --git a/test/files/run/blame_eye_triple_eee.check b/test/files/run/blame_eye_triple_eee-double.check index 5e46d91a8f..5e46d91a8f 100644 --- a/test/files/run/blame_eye_triple_eee.check +++ b/test/files/run/blame_eye_triple_eee-double.check diff --git a/test/files/run/blame_eye_triple_eee.flags b/test/files/run/blame_eye_triple_eee-double.flags index c9b68d70dc..c9b68d70dc 100644 --- a/test/files/run/blame_eye_triple_eee.flags +++ b/test/files/run/blame_eye_triple_eee-double.flags diff --git a/test/files/run/blame_eye_triple_eee.scala b/test/files/run/blame_eye_triple_eee-double.scala index 1640aead40..1640aead40 100644 --- a/test/files/run/blame_eye_triple_eee.scala +++ b/test/files/run/blame_eye_triple_eee-double.scala diff --git a/test/files/run/blame_eye_triple_eee-float.check b/test/files/run/blame_eye_triple_eee-float.check new file mode 100644 index 0000000000..5e46d91a8f --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.check @@ -0,0 +1,9 @@ +if (NaN == NaN) is good +if (x == x) is good +if (x == NaN) is good +if (NaN != NaN) is good +if (x != x) is good +if (NaN != x) is good +x matching was good +NaN matching was good +loop with NaN was goood diff --git a/test/files/run/blame_eye_triple_eee-float.flags b/test/files/run/blame_eye_triple_eee-float.flags new file mode 100644 index 0000000000..c9b68d70dc --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.flags @@ -0,0 +1 @@ +-optimise diff --git a/test/files/run/blame_eye_triple_eee-float.scala b/test/files/run/blame_eye_triple_eee-float.scala new file mode 100644 index 0000000000..4deb9f3d60 --- /dev/null +++ b/test/files/run/blame_eye_triple_eee-float.scala @@ -0,0 +1,61 @@ +object Test extends App { + import Float.NaN + + // NaN must not equal NaN no matter what optimizations are applied + // All the following will seem redundant, but to an optimizer + // they can appear different + + val x = NaN + + if (NaN == NaN) + println("if (NaN == NaN) is broken") + else + println("if (NaN == NaN) is good") + + if (x == x) + println("if (x == x) is broken") + else + println("if (x == x) is good") + + if (x == NaN) + println("if (x == NaN) is broken") + else + println("if (x == NaN) is good") + + if (NaN != NaN) + println("if (NaN != NaN) is good") + else + println("if (NaN != NaN) broken") + + if (x != x) + println("if (x != x) is good") + else + println("if (x != x) broken") + + if (NaN != x) + println("if (NaN != x) is good") + else + println("if (NaN != x) is broken") + + x match { + case 0.0f => println("x matched 0!") + case NaN => println("x matched NaN!") + case _ => println("x matching was good") + } + + NaN match { + case 0.0f => println("NaN matched 0!") + case NaN => println("NaN matched NaN!") + case _ => println("NaN matching was good") + } + + var z = 0.0f + var i = 0 + while (i < 10) { + if (i % 2 == 0) z = NaN + else z = NaN + i += 1 + } + if (z.isNaN && i == 10) println("loop with NaN was goood") + else println("loop with NaN was broken") +} |