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
@@ -16,40 +16,40 @@
package kotlin.js.internal
private object DoubleCompanionObject : FloatingPointConstants<Double> {
override val MIN_VALUE: Double = js("Number.MIN_VALUE")
override val MAX_VALUE: Double = js("Number.MAX_VALUE")
override val POSITIVE_INFINITY: Double = js("Number.POSITIVE_INFINITY")
override val NEGATIVE_INFINITY: Double = js("Number.NEGATIVE_INFINITY")
override val NaN: Double = js("Number.NaN")
private object DoubleCompanionObject {
val MIN_VALUE: Double = js("Number.MIN_VALUE")
val MAX_VALUE: Double = js("Number.MAX_VALUE")
val POSITIVE_INFINITY: Double = js("Number.POSITIVE_INFINITY")
val NEGATIVE_INFINITY: Double = js("Number.NEGATIVE_INFINITY")
val NaN: Double = js("Number.NaN")
}
private object FloatCompanionObject : FloatingPointConstants<Float> {
override val MIN_VALUE: Float = js("Number.MIN_VALUE")
override val MAX_VALUE: Float = js("Number.MAX_VALUE")
override val POSITIVE_INFINITY : Float = js("Number.POSITIVE_INFINITY")
override val NEGATIVE_INFINITY : Float = js("Number.NEGATIVE_INFINITY")
override val NaN : Float = js("Number.NaN")
private object FloatCompanionObject {
val MIN_VALUE: Float = js("Number.MIN_VALUE")
val MAX_VALUE: Float = js("Number.MAX_VALUE")
val POSITIVE_INFINITY : Float = js("Number.POSITIVE_INFINITY")
val NEGATIVE_INFINITY : Float = js("Number.NEGATIVE_INFINITY")
val NaN : Float = js("Number.NaN")
}
private object IntCompanionObject : IntegerConstants<Int> {
override val MIN_VALUE: Int = -0x80000000
override val MAX_VALUE: Int = 0x7FFFFFFF
private object IntCompanionObject {
val MIN_VALUE: Int = -2147483647 - 1
val MAX_VALUE: Int = 2147483647
}
private object LongCompanionObject : IntegerConstants<Long> {
override val MIN_VALUE: Long = js("Kotlin.Long.MIN_VALUE")
override val MAX_VALUE: Long = js("Kotlin.Long.MAX_VALUE")
private object LongCompanionObject {
val MIN_VALUE: Long = js("Kotlin.Long.MIN_VALUE")
val MAX_VALUE: Long = js("Kotlin.Long.MAX_VALUE")
}
private object ShortCompanionObject : IntegerConstants<Short> {
override val MIN_VALUE: Short = -0x8000
override val MAX_VALUE: Short = 0x7FFF
private object ShortCompanionObject {
val MIN_VALUE: Short = -32768
val MAX_VALUE: Short = 32767
}
private object ByteCompanionObject : IntegerConstants<Byte> {
override val MIN_VALUE: Byte = -0x80
override val MAX_VALUE: Byte = 0x7F
private object ByteCompanionObject {
val MIN_VALUE: Byte = -128
val MAX_VALUE: Byte = 127
}
private object CharCompanionObject {}
@@ -0,0 +1,26 @@
package test.js
import org.junit.Test as test
import kotlin.test.*
class NumbersJsTest {
@test fun longMinMaxValues() {
assertEquals(js("Kotlin.Long.MIN_VALUE"), Long.MIN_VALUE)
assertEquals(js("Kotlin.Long.MAX_VALUE"), Long.MAX_VALUE)
}
@test fun doubleMinMaxValues() {
assertEquals(js("Number.MIN_VALUE"), Double.MIN_VALUE)
assertEquals(js("Number.MAX_VALUE"), Double.MAX_VALUE)
assertEquals(js("Number.POSITIVE_INFINITY"), Double.POSITIVE_INFINITY)
assertEquals(js("Number.NEGATIVE_INFINITY"), Double.NEGATIVE_INFINITY)
}
@test fun floatMinMaxValues() {
assertEquals(js("Number.MIN_VALUE"), Float.MIN_VALUE)
assertEquals(js("Number.MAX_VALUE"), Float.MAX_VALUE)
assertEquals(js("Number.POSITIVE_INFINITY"), Float.POSITIVE_INFINITY)
assertEquals(js("Number.NEGATIVE_INFINITY"), Float.NEGATIVE_INFINITY)
}
}