Add tests for primitive companion object

Update test data
This commit is contained in:
Roman Artemev
2018-08-23 16:41:25 +03:00
committed by romanart
parent 450ed63690
commit cc14442be1
25 changed files with 384 additions and 13 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
fun Int.thisRef1() = fun () = this
fun Int.thisRef2() = fun (): Int {return this}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -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"
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// WITH_RUNTIME
const val M = Int.MIN_VALUE
@@ -1,5 +1,4 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
const val M = Int.MAX_VALUE
fun box(): String {
@@ -14631,6 +14631,54 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testProtectedCompanionObjectAccessedFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt");
}
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrimitiveCompanion extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInPrimitiveCompanion() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("byteCompanionObject.kt")
public void testByteCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/byteCompanionObject.kt");
}
@TestMetadata("charCompanionObject.kt")
public void testCharCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/charCompanionObject.kt");
}
@TestMetadata("doubleCompanionObject.kt")
public void testDoubleCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/doubleCompanionObject.kt");
}
@TestMetadata("floatCompanionObject.kt")
public void testFloatCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/floatCompanionObject.kt");
}
@TestMetadata("intCompanionObject.kt")
public void testIntCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/intCompanionObject.kt");
}
@TestMetadata("longCompanionObject.kt")
public void testLongCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/longCompanionObject.kt");
}
@TestMetadata("shortCompanionObject.kt")
public void testShortCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/shortCompanionObject.kt");
}
}
}
}
@@ -14631,6 +14631,54 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testProtectedCompanionObjectAccessedFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt");
}
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrimitiveCompanion extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInPrimitiveCompanion() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("byteCompanionObject.kt")
public void testByteCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/byteCompanionObject.kt");
}
@TestMetadata("charCompanionObject.kt")
public void testCharCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/charCompanionObject.kt");
}
@TestMetadata("doubleCompanionObject.kt")
public void testDoubleCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/doubleCompanionObject.kt");
}
@TestMetadata("floatCompanionObject.kt")
public void testFloatCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/floatCompanionObject.kt");
}
@TestMetadata("intCompanionObject.kt")
public void testIntCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/intCompanionObject.kt");
}
@TestMetadata("longCompanionObject.kt")
public void testLongCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/longCompanionObject.kt");
}
@TestMetadata("shortCompanionObject.kt")
public void testShortCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/shortCompanionObject.kt");
}
}
}
}
@@ -14631,6 +14631,54 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testProtectedCompanionObjectAccessedFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt");
}
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrimitiveCompanion extends AbstractIrBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInPrimitiveCompanion() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("byteCompanionObject.kt")
public void testByteCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/byteCompanionObject.kt");
}
@TestMetadata("charCompanionObject.kt")
public void testCharCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/charCompanionObject.kt");
}
@TestMetadata("doubleCompanionObject.kt")
public void testDoubleCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/doubleCompanionObject.kt");
}
@TestMetadata("floatCompanionObject.kt")
public void testFloatCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/floatCompanionObject.kt");
}
@TestMetadata("intCompanionObject.kt")
public void testIntCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/intCompanionObject.kt");
}
@TestMetadata("longCompanionObject.kt")
public void testLongCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/longCompanionObject.kt");
}
@TestMetadata("shortCompanionObject.kt")
public void testShortCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/shortCompanionObject.kt");
}
}
}
}
@@ -12841,6 +12841,54 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testProtectedCompanionObjectAccessedFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt");
}
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrimitiveCompanion extends AbstractIrJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
public void testAllFilesPresentInPrimitiveCompanion() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
}
@TestMetadata("byteCompanionObject.kt")
public void testByteCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/byteCompanionObject.kt");
}
@TestMetadata("charCompanionObject.kt")
public void testCharCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/charCompanionObject.kt");
}
@TestMetadata("doubleCompanionObject.kt")
public void testDoubleCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/doubleCompanionObject.kt");
}
@TestMetadata("floatCompanionObject.kt")
public void testFloatCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/floatCompanionObject.kt");
}
@TestMetadata("intCompanionObject.kt")
public void testIntCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/intCompanionObject.kt");
}
@TestMetadata("longCompanionObject.kt")
public void testLongCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/longCompanionObject.kt");
}
@TestMetadata("shortCompanionObject.kt")
public void testShortCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/shortCompanionObject.kt");
}
}
}
}
@@ -13901,6 +13901,54 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testProtectedCompanionObjectAccessedFromNestedClass() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/protectedCompanionObjectAccessedFromNestedClass.kt");
}
@TestMetadata("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class PrimitiveCompanion extends AbstractJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
public void testAllFilesPresentInPrimitiveCompanion() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("byteCompanionObject.kt")
public void testByteCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/byteCompanionObject.kt");
}
@TestMetadata("charCompanionObject.kt")
public void testCharCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/charCompanionObject.kt");
}
@TestMetadata("doubleCompanionObject.kt")
public void testDoubleCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/doubleCompanionObject.kt");
}
@TestMetadata("floatCompanionObject.kt")
public void testFloatCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/floatCompanionObject.kt");
}
@TestMetadata("intCompanionObject.kt")
public void testIntCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/intCompanionObject.kt");
}
@TestMetadata("longCompanionObject.kt")
public void testLongCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/longCompanionObject.kt");
}
@TestMetadata("shortCompanionObject.kt")
public void testShortCompanionObject() throws Exception {
runTest("compiler/testData/codegen/box/objects/companionObjectAccess/primitiveCompanion/shortCompanionObject.kt");
}
}
}
}
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1115
package foo
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1115
package foo
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1116
package foo
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JS_IR
// EXPECTED_REACHABLE_NODES: 1135
// CHECK_CONTAINS_NO_CALLS: inRange
// CHECK_CONTAINS_NO_CALLS: inRange2