JS: Provide MIN_VALUE and MAX_VALUE member constants for Int, Long, Short and Byte companion objects.
JVM: Make MIN_VALUE and MAX_VALUE not an extension but member constant properties of Int, Long, Short and Byte companion objects.
This commit is contained in:
@@ -5,6 +5,40 @@ import kotlin.test.*
|
||||
|
||||
class NumbersTest {
|
||||
|
||||
|
||||
test fun intMinMaxValues() {
|
||||
assertTrue(Int.MIN_VALUE < 0)
|
||||
assertTrue(Int.MAX_VALUE > 0)
|
||||
|
||||
// overflow behavior
|
||||
// doesn't hold for JS Number
|
||||
// assertEquals(Int.MIN_VALUE, Int.MAX_VALUE + 1)
|
||||
}
|
||||
|
||||
test fun longMinMaxValues() {
|
||||
assertTrue(Long.MIN_VALUE < 0)
|
||||
assertTrue(Long.MAX_VALUE > 0)
|
||||
// overflow behavior
|
||||
assertEquals(Long.MIN_VALUE, Long.MAX_VALUE + 1)
|
||||
assertEquals(Long.MAX_VALUE, Long.MIN_VALUE - 1)
|
||||
}
|
||||
|
||||
test fun shortMinMaxValues() {
|
||||
assertTrue(Short.MIN_VALUE < 0)
|
||||
assertTrue(Short.MAX_VALUE > 0)
|
||||
// overflow behavior
|
||||
assertEquals(Short.MIN_VALUE, (Short.MAX_VALUE + 1).toShort())
|
||||
assertEquals(Short.MAX_VALUE, (Short.MIN_VALUE - 1).toShort())
|
||||
}
|
||||
|
||||
test fun byteMinMaxValues() {
|
||||
assertTrue(Byte.MIN_VALUE < 0)
|
||||
assertTrue(Byte.MAX_VALUE > 0)
|
||||
// overflow behavior
|
||||
assertEquals(Byte.MIN_VALUE, (Byte.MAX_VALUE + 1).toByte())
|
||||
assertEquals(Byte.MAX_VALUE, (Byte.MIN_VALUE - 1).toByte())
|
||||
}
|
||||
|
||||
test fun doubleProperties() {
|
||||
for (value in listOf(1.0, 0.0))
|
||||
doTestNumber(value)
|
||||
|
||||
Reference in New Issue
Block a user