@@ -36,6 +36,12 @@ class LongTest {
36
36
37
37
// Helpers
38
38
39
+ final def assertExactEquals (expected : Float , actual : Float ): Unit =
40
+ assertTrue(s " expected: $expected; actual: $actual" , expected.equals(actual))
41
+
42
+ final def assertExactEquals (expected : Double , actual : Double ): Unit =
43
+ assertTrue(s " expected: $expected; actual: $actual" , expected.equals(actual))
44
+
39
45
@ noinline def hideFromOptimizer (x : Long ): Long = x
40
46
41
47
@ noinline def hideDoubleFromOptimizer (x : Double ): Double = x
@@ -616,18 +622,16 @@ class LongTest {
616
622
}
617
623
618
624
@ Test def toFloat (): Unit = {
619
- @ inline def test (expected : Float , x : Long , epsilon : Float = 0.0f ): Unit = {
620
- assertEquals (expected, x.toFloat, epsilon )
621
- assertEquals (expected, hideFromOptimizer(x).toFloat, epsilon )
625
+ @ inline def test (expected : Float , x : Long ): Unit = {
626
+ assertExactEquals (expected, x.toFloat)
627
+ assertExactEquals (expected, hideFromOptimizer(x).toFloat)
622
628
}
623
629
624
630
test(0 , lg(0 ))
625
631
test(- 1 , lg(- 1 ))
626
632
627
- // Closure seems to incorrectly rewrite the constant on the right :-(
628
- val epsilon = if (usesClosureCompiler) 1E4f else 0.0f
629
- test(9.223372E18f , MaxVal , epsilon)
630
- test(- 9.223372E18f , MinVal , epsilon)
633
+ test(9.223372E18f , MaxVal )
634
+ test(- 9.223372E18f , MinVal )
631
635
632
636
test(4.7971489E18f , lg(- 1026388143 , 1116923232 ))
633
637
test(- 2.24047663E18f , lg(- 1288678667 , - 521651607 ))
@@ -670,18 +674,16 @@ class LongTest {
670
674
}
671
675
672
676
@ Test def toDouble (): Unit = {
673
- @ inline def test (expected : Double , x : Long , epsilon : Double = 0.0 ): Unit = {
674
- assertEquals (expected, x.toDouble, epsilon )
675
- assertEquals (expected, hideFromOptimizer(x).toDouble, epsilon )
677
+ @ inline def test (expected : Double , x : Long ): Unit = {
678
+ assertExactEquals (expected, x.toDouble)
679
+ assertExactEquals (expected, hideFromOptimizer(x).toDouble)
676
680
}
677
681
678
682
test(0 , lg(0 ))
679
683
test(- 1 , lg(- 1 ))
680
684
681
- // Closure seems to incorrectly rewrite the constant on the right :-(
682
- val epsilon = if (usesClosureCompiler) 1E4 else 0.0
683
- test(9.223372036854776E18 , MaxVal , epsilon)
684
- test(- 9.223372036854776E18 , MinVal , epsilon)
685
+ test(9.223372036854776E18 , MaxVal )
686
+ test(- 9.223372036854776E18 , MinVal )
685
687
686
688
test(3.4240179834317537E18 , lg(- 151011088 , 797216310 ))
687
689
test(8.5596043411285968E16 , lg(- 508205099 , 19929381 ))
@@ -727,11 +729,8 @@ class LongTest {
727
729
test(lg(0 ), - Double .MinPositiveValue )
728
730
test(MaxVal , twoPow63)
729
731
test(MaxVal , twoPow63NextUp)
730
- if (! usesClosureCompiler) {
731
- // GCC incorrectly rewrites the Double constants on the rhs
732
- test(lg(- 1024 , 2147483647 ), twoPow63NextDown)
733
- test(MinVal , - twoPow63)
734
- }
732
+ test(lg(- 1024 , 2147483647 ), twoPow63NextDown)
733
+ test(MinVal , - twoPow63)
735
734
test(MinVal , - twoPow63NextUp)
736
735
test(lg(1024 , - 2147483648 ), - twoPow63NextDown)
737
736
0 commit comments