Add tests for primitive companion object
Update test data
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Byte.Companion.MAX() = MAX_VALUE
|
||||
fun Byte.Companion.MIN() = MIN_VALUE
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Byte.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(127, Byte.MAX_VALUE)
|
||||
|
||||
assertEquals(Byte.MIN_VALUE, Byte.MIN())
|
||||
assertEquals(Byte.MAX_VALUE, Byte.Companion.MAX())
|
||||
|
||||
test(Byte)
|
||||
test(Byte.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Char.Companion.MAX() = MAX_SURROGATE
|
||||
fun Char.Companion.MIN() = MIN_SURROGATE
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Char.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals('\uDFFF', Char.MAX_SURROGATE)
|
||||
|
||||
assertEquals(Char.MIN_SURROGATE, Char.MIN())
|
||||
assertEquals(Char.MAX_SURROGATE, Char.Companion.MAX())
|
||||
|
||||
test(Char)
|
||||
test(Char.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Double.Companion.MAX() = MAX_VALUE
|
||||
fun Double.Companion.MIN() = MIN_VALUE
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Double.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(1.7976931348623157E308, Double.MAX_VALUE)
|
||||
|
||||
assertEquals(Double.MIN_VALUE, Double.MIN())
|
||||
assertEquals(Double.MAX_VALUE, Double.Companion.MAX())
|
||||
|
||||
test(Double)
|
||||
test(Double.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Float.Companion.MAX() = POSITIVE_INFINITY
|
||||
fun Float.Companion.MIN() = NEGATIVE_INFINITY
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Float.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(1.0f / 0.0f, Float.POSITIVE_INFINITY)
|
||||
|
||||
assertEquals(Float.NEGATIVE_INFINITY, Float.MIN())
|
||||
assertEquals(Float.POSITIVE_INFINITY, Float.Companion.MAX())
|
||||
|
||||
test(Float)
|
||||
test(Float.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/intCompanionObject.kt
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Int.Companion.MAX() = MAX_VALUE
|
||||
fun Int.Companion.MIN() = MIN_VALUE
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Int.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(2147483647, Int.MAX_VALUE)
|
||||
|
||||
assertEquals(Int.MIN_VALUE, Int.MIN())
|
||||
assertEquals(Int.MAX_VALUE, Int.Companion.MAX())
|
||||
|
||||
test(Int)
|
||||
test(Int.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Long.Companion.MAX() = MAX_VALUE
|
||||
fun Long.Companion.MIN() = MIN_VALUE
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Long.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(9223372036854775807L, Long.MAX_VALUE)
|
||||
|
||||
assertEquals(Long.MIN_VALUE, Long.MIN())
|
||||
assertEquals(Long.MAX_VALUE, Long.Companion.MAX())
|
||||
|
||||
test(Long)
|
||||
test(Long.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun <T> assertEquals(a: T, b: T) { if (a != b) throw AssertionError("$a != $b") }
|
||||
|
||||
fun Short.Companion.MAX() = MAX_VALUE
|
||||
fun Short.Companion.MIN() = MIN_VALUE
|
||||
|
||||
fun <T> test(o: T) { assertEquals(o === Short.Companion, true) }
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(32767, Short.MAX_VALUE)
|
||||
|
||||
assertEquals(Short.MIN_VALUE, Short.MIN())
|
||||
assertEquals(Short.MAX_VALUE, Short.Companion.MAX())
|
||||
|
||||
test(Short)
|
||||
test(Short.Companion)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user