Uncomment some assertions for overflow behavior that now can pass in JS
This commit is contained in:
@@ -20,6 +20,8 @@ object NumbersTestConstants {
|
|||||||
class NumbersTest {
|
class NumbersTest {
|
||||||
|
|
||||||
var one: Int = 1
|
var one: Int = 1
|
||||||
|
var oneS: Short = 1
|
||||||
|
var oneB: Byte = 1
|
||||||
|
|
||||||
@Test fun intMinMaxValues() {
|
@Test fun intMinMaxValues() {
|
||||||
assertTrue(Int.MIN_VALUE < 0)
|
assertTrue(Int.MIN_VALUE < 0)
|
||||||
@@ -29,9 +31,8 @@ class NumbersTest {
|
|||||||
assertEquals(NumbersTestConstants.intMaxPred, Int.MAX_VALUE - one)
|
assertEquals(NumbersTestConstants.intMaxPred, Int.MAX_VALUE - one)
|
||||||
|
|
||||||
// overflow behavior
|
// overflow behavior
|
||||||
// doesn't hold for JS Number
|
expect(Int.MIN_VALUE) { Int.MAX_VALUE + one }
|
||||||
// expect(Int.MIN_VALUE) { Int.MAX_VALUE + 1 }
|
expect(Int.MAX_VALUE) { Int.MIN_VALUE - one }
|
||||||
// expect(Int.MAX_VALUE) { Int.MIN_VALUE - 1 }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun longMinMaxValues() {
|
@Test fun longMinMaxValues() {
|
||||||
@@ -42,8 +43,8 @@ class NumbersTest {
|
|||||||
assertEquals(NumbersTestConstants.longMaxPred, Long.MAX_VALUE - one)
|
assertEquals(NumbersTestConstants.longMaxPred, Long.MAX_VALUE - one)
|
||||||
|
|
||||||
// overflow behavior
|
// overflow behavior
|
||||||
expect(Long.MIN_VALUE) { Long.MAX_VALUE + 1 }
|
expect(Long.MIN_VALUE) { Long.MAX_VALUE + one }
|
||||||
expect(Long.MAX_VALUE) { Long.MIN_VALUE - 1 }
|
expect(Long.MAX_VALUE) { Long.MIN_VALUE - one }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun shortMinMaxValues() {
|
@Test fun shortMinMaxValues() {
|
||||||
@@ -54,8 +55,8 @@ class NumbersTest {
|
|||||||
assertEquals(NumbersTestConstants.shortMaxPred, Short.MAX_VALUE.dec())
|
assertEquals(NumbersTestConstants.shortMaxPred, Short.MAX_VALUE.dec())
|
||||||
|
|
||||||
// overflow behavior
|
// overflow behavior
|
||||||
expect(Short.MIN_VALUE) { (Short.MAX_VALUE + 1).toShort() }
|
expect(Short.MIN_VALUE) { (Short.MAX_VALUE + oneS).toShort() }
|
||||||
expect(Short.MAX_VALUE) { (Short.MIN_VALUE - 1).toShort() }
|
expect(Short.MAX_VALUE) { (Short.MIN_VALUE - oneS).toShort() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun byteMinMaxValues() {
|
@Test fun byteMinMaxValues() {
|
||||||
@@ -66,8 +67,8 @@ class NumbersTest {
|
|||||||
assertEquals(NumbersTestConstants.byteMaxPred, Byte.MAX_VALUE.dec())
|
assertEquals(NumbersTestConstants.byteMaxPred, Byte.MAX_VALUE.dec())
|
||||||
|
|
||||||
// overflow behavior
|
// overflow behavior
|
||||||
expect(Byte.MIN_VALUE) { (Byte.MAX_VALUE + 1).toByte() }
|
expect(Byte.MIN_VALUE) { (Byte.MAX_VALUE + oneB).toByte() }
|
||||||
expect(Byte.MAX_VALUE) { (Byte.MIN_VALUE - 1).toByte() }
|
expect(Byte.MAX_VALUE) { (Byte.MIN_VALUE - oneB).toByte() }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun doubleMinMaxValues() {
|
@Test fun doubleMinMaxValues() {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class RangeTest {
|
|||||||
assertFalse(10.toByte() in openRange)
|
assertFalse(10.toByte() in openRange)
|
||||||
|
|
||||||
// byte arguments now construct IntRange so no overflow here
|
// 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())
|
assertTrue((0.toByte() until Int.MIN_VALUE).isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,8 +103,7 @@ public class RangeTest {
|
|||||||
assertTrue(9.toShort() in openRange)
|
assertTrue(9.toShort() in openRange)
|
||||||
assertFalse(10.toShort() in openRange)
|
assertFalse(10.toShort() in openRange)
|
||||||
|
|
||||||
// short arguments now construct IntRange so no overflow here
|
assertTrue((0.toShort() until Short.MIN_VALUE).isEmpty())
|
||||||
// assertTrue(assertFails { 0.toShort() until Short.MIN_VALUE } is IllegalArgumentException)
|
|
||||||
assertTrue((0.toShort() until Int.MIN_VALUE).isEmpty())
|
assertTrue((0.toShort() until Int.MIN_VALUE).isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user