summaryrefslogtreecommitdiff
path: root/test/files/run/blame_eye_triple_eee-double.scala
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2013-04-04 17:13:04 +0200
committerSimon Ochsenreither <simon@ochsenreither.de>2013-04-04 17:13:04 +0200
commit497b0cb09a750fe05cf6c7c1cae2e3b960772ec4 (patch)
treef187efe143b93046f23c5f003def7e5f480e41ab /test/files/run/blame_eye_triple_eee-double.scala
parentcea9e4a9d368965fd37940ef0b7aedd10bec261e (diff)
downloadscala-497b0cb09a750fe05cf6c7c1cae2e3b960772ec4.tar.gz
scala-497b0cb09a750fe05cf6c7c1cae2e3b960772ec4.tar.bz2
scala-497b0cb09a750fe05cf6c7c1cae2e3b960772ec4.zip
Add float version of the double NaN tests
The double version uncovered a bug in Avian already, so let's be safe and cover all the NaNs we have.
Diffstat (limited to 'test/files/run/blame_eye_triple_eee-double.scala')
-rw-r--r--test/files/run/blame_eye_triple_eee-double.scala61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/files/run/blame_eye_triple_eee-double.scala b/test/files/run/blame_eye_triple_eee-double.scala
new file mode 100644
index 0000000000..1640aead40
--- /dev/null
+++ b/test/files/run/blame_eye_triple_eee-double.scala
@@ -0,0 +1,61 @@
+object Test extends App {
+ import Double.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.0d => println("x matched 0!")
+ case NaN => println("x matched NaN!")
+ case _ => println("x matching was good")
+ }
+
+ NaN match {
+ case 0.0d => println("NaN matched 0!")
+ case NaN => println("NaN matched NaN!")
+ case _ => println("NaN matching was good")
+ }
+
+ var z = 0.0d
+ 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")
+}