Skip to content

Commit 263e02f

Browse files
committed
Port tests from Scala2 #5207
scala/scala#5207
1 parent 10cc2f8 commit 263e02f

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

compiler/src/dotty/tools/backend/ScalaPrimitivesOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class ScalaPrimitivesOps {
3333
final val NE = 43 // x != y
3434
final val LT = 44 // x < y
3535
final val LE = 45 // x <= y
36-
final val GE = 46 // x > y
37-
final val GT = 47 // x >= y
36+
final val GT = 46 // x > y
37+
final val GE = 47 // x >= y
3838

3939
// Boolean unary operations
4040
final val ZNOT = 50 // !x

tests/run-bootstrapped/i6710.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,36 @@ object Test {
1919
while(x > 10.0) { x = x + 1; println(x) }
2020
do { x = x + 1; println(x) } while(x < 10.0)
2121
do { x = x + 1; println(x) } while(x > 10.0)
22+
23+
// tests from https://github.com/scala/scala/pull/5207
24+
{
25+
val n = Double.NaN
26+
def ne(x: Double, y: Double) = x != y
27+
val fs: List[(Double, Double) => Boolean] = List(_ < _, _ <= _, _ > _, _ >= _, _ == _, (x, y) => !ne(x, y))
28+
val vs = List[Double](n, 1, -1, 0)
29+
for (f <- fs; v <- vs; (x, y) <- List((n, v), (v, n))) assert(!f(x, y))
30+
}
31+
32+
{
33+
val n = Float.NaN
34+
def ne(x: Float, y: Float) = x != y
35+
val fs: List[(Float, Float) => Boolean] = List(_ < _, _ <= _, _ > _, _ >= _, _ == _, (x, y) => !ne(x, y))
36+
val vs = List[Float](n, 1, -1, 0)
37+
for (f <- fs; v <- vs; (x, y) <- List((n, v), (v, n))) assert(!f(x, y))
38+
}
39+
40+
{
41+
def a[T](x: T, y: T) = x == y
42+
def b[T](x: T, y: T) = x != y
43+
val n = Double.NaN
44+
(a(n, n) :: a(n, 0) :: a (0, n) :: !b(n, n) :: !b(n, 0) :: !b(0, n) :: Nil).foreach(b => assert(!b))
45+
}
46+
47+
{
48+
def a[T](x: T, y: T) = x == y
49+
def b[T](x: T, y: T) = x != y
50+
val n = Float.NaN
51+
(a(n, n) :: a(n, 0) :: a (0, n) :: !b(n, n) :: !b(n, 0) :: !b(0, n) :: Nil).foreach(b => assert(!b))
52+
}
2253
}
2354
}

0 commit comments

Comments
 (0)