Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 497b0cb09a750fe05cf6c7c1cae2e3b960772ec4 1 parent cea9e4a
@soc soc authored
View
0  test/files/run/blame_eye_triple_eee.check → ...les/run/blame_eye_triple_eee-double.check
File renamed without changes
View
0  test/files/run/blame_eye_triple_eee.flags → ...les/run/blame_eye_triple_eee-double.flags
File renamed without changes
View
0  test/files/run/blame_eye_triple_eee.scala → ...les/run/blame_eye_triple_eee-double.scala
File renamed without changes
View
9 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
View
1  test/files/run/blame_eye_triple_eee-float.flags
@@ -0,0 +1 @@
+-optimise
View
61 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")
+}
Please sign in to comment.
Something went wrong with that request. Please try again.