Uncomment some assertions for overflow behavior that now can pass in JS

This commit is contained in:
Ilya Gorbunov
2016-12-20 23:01:34 +03:00
parent 6b509892cb
commit c43e4f6682
2 changed files with 12 additions and 12 deletions
+10 -9
View File
@@ -20,6 +20,8 @@ object NumbersTestConstants {
class NumbersTest {
var one: Int = 1
var oneS: Short = 1
var oneB: Byte = 1
@Test fun intMinMaxValues() {
assertTrue(Int.MIN_VALUE < 0)
@@ -29,9 +31,8 @@ class NumbersTest {
assertEquals(NumbersTestConstants.intMaxPred, Int.MAX_VALUE - one)
// overflow behavior
// doesn't hold for JS Number
// expect(Int.MIN_VALUE) { Int.MAX_VALUE + 1 }
// expect(Int.MAX_VALUE) { Int.MIN_VALUE - 1 }
expect(Int.MIN_VALUE) { Int.MAX_VALUE + one }
expect(Int.MAX_VALUE) { Int.MIN_VALUE - one }
}
@Test fun longMinMaxValues() {
@@ -42,8 +43,8 @@ class NumbersTest {
assertEquals(NumbersTestConstants.longMaxPred, Long.MAX_VALUE - one)
// overflow behavior
expect(Long.MIN_VALUE) { Long.MAX_VALUE + 1 }
expect(Long.MAX_VALUE) { Long.MIN_VALUE - 1 }
expect(Long.MIN_VALUE) { Long.MAX_VALUE + one }
expect(Long.MAX_VALUE) { Long.MIN_VALUE - one }
}
@Test fun shortMinMaxValues() {
@@ -54,8 +55,8 @@ class NumbersTest {
assertEquals(NumbersTestConstants.shortMaxPred, Short.MAX_VALUE.dec())
// overflow behavior
expect(Short.MIN_VALUE) { (Short.MAX_VALUE + 1).toShort() }
expect(Short.MAX_VALUE) { (Short.MIN_VALUE - 1).toShort() }
expect(Short.MIN_VALUE) { (Short.MAX_VALUE + oneS).toShort() }
expect(Short.MAX_VALUE) { (Short.MIN_VALUE - oneS).toShort() }
}
@Test fun byteMinMaxValues() {
@@ -66,8 +67,8 @@ class NumbersTest {
assertEquals(NumbersTestConstants.byteMaxPred, Byte.MAX_VALUE.dec())
// overflow behavior
expect(Byte.MIN_VALUE) { (Byte.MAX_VALUE + 1).toByte() }
expect(Byte.MAX_VALUE) { (Byte.MIN_VALUE - 1).toByte() }
expect(Byte.MIN_VALUE) { (Byte.MAX_VALUE + oneB).toByte() }
expect(Byte.MAX_VALUE) { (Byte.MIN_VALUE - oneB).toByte() }
}
@Test fun doubleMinMaxValues() {
+2 -3
View File
@@ -70,7 +70,7 @@ public class RangeTest {
assertFalse(10.toByte() in openRange)
// byte arguments now construct IntRange so no overflow here
// assertTrue(assertFails { 0.toByte() until Byte.MIN_VALUE } is IllegalArgumentException)
assertTrue((0.toByte() until Byte.MIN_VALUE).isEmpty())
assertTrue((0.toByte() until Int.MIN_VALUE).isEmpty())
}
@@ -103,8 +103,7 @@ public class RangeTest {
assertTrue(9.toShort() in openRange)
assertFalse(10.toShort() in openRange)
// short arguments now construct IntRange so no overflow here
// assertTrue(assertFails { 0.toShort() until Short.MIN_VALUE } is IllegalArgumentException)
assertTrue((0.toShort() until Short.MIN_VALUE).isEmpty())
assertTrue((0.toShort() until Int.MIN_VALUE).isEmpty())
}