[TEST] Migrate AbstractDiagnosticsWithUnsignedTypes to new test runners

This commit is contained in:
Dmitriy Novozhilov
2020-12-09 12:40:17 +03:00
parent 23e704f361
commit b43fa94cb6
56 changed files with 598 additions and 173 deletions
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun ubyte(vararg a: UByte) {}
fun ushort(vararg a: UShort) {}
fun uint(vararg a: UInt) {}
fun ulong(vararg a: ULong) {}
class ValueParam(vararg val a: ULong)
annotation class Ann(vararg val a: <!INVALID_TYPE_OF_ANNOTATION_MEMBER!>UInt<!>)
fun array(vararg a: UIntArray) {}
@@ -0,0 +1 @@
val foo = <!INAPPLICABLE_CANDIDATE!>UInt<!>()
@@ -1 +1 @@
val foo = <!INVISIBLE_MEMBER!>UInt<!>(<!NO_VALUE_FOR_PARAMETER!>)<!>
val foo = <!INVISIBLE_MEMBER!>UInt<!>(<!NO_VALUE_FOR_PARAMETER!>)<!>
@@ -0,0 +1,69 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !WITH_NEW_INFERENCE
// FILE: annotation.kt
package kotlin.internal
annotation class ImplicitIntegerCoercion
// FILE: test.kt
import kotlin.internal.ImplicitIntegerCoercion
@ImplicitIntegerCoercion
const val IMPLICIT_INT = 255
@ImplicitIntegerCoercion
const val EXPLICIT_INT: Int = 255
@ImplicitIntegerCoercion
const val LONG_CONST = 255L
@ImplicitIntegerCoercion
val NON_CONST = 255
@ImplicitIntegerCoercion
const val BIGGER_THAN_UBYTE = 256
@ImplicitIntegerCoercion
const val UINT_CONST = 42u
fun takeUByte(@ImplicitIntegerCoercion u: UByte) {}
fun takeUShort(@ImplicitIntegerCoercion u: UShort) {}
fun takeUInt(@ImplicitIntegerCoercion u: UInt) {}
fun takeULong(@ImplicitIntegerCoercion u: ULong) {}
fun takeUBytes(@ImplicitIntegerCoercion vararg u: UByte) {}
fun takeLong(@ImplicitIntegerCoercion l: Long) {}
fun takeUIntWithoutAnnotaion(u: UInt) {}
fun takeIntWithoutAnnotation(i: Int) {}
fun test() {
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(IMPLICIT_INT)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(EXPLICIT_INT)
<!INAPPLICABLE_CANDIDATE!>takeUShort<!>(IMPLICIT_INT)
<!INAPPLICABLE_CANDIDATE!>takeUShort<!>(BIGGER_THAN_UBYTE)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(IMPLICIT_INT)
<!INAPPLICABLE_CANDIDATE!>takeULong<!>(IMPLICIT_INT)
<!INAPPLICABLE_CANDIDATE!>takeUBytes<!>(IMPLICIT_INT, EXPLICIT_INT, 42u)
<!INAPPLICABLE_CANDIDATE!>takeLong<!>(IMPLICIT_INT)
takeIntWithoutAnnotation(IMPLICIT_INT)
takeUIntWithoutAnnotaion(UINT_CONST)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(LONG_CONST)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(NON_CONST)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(BIGGER_THAN_UBYTE)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(UINT_CONST)
<!INAPPLICABLE_CANDIDATE!>takeUIntWithoutAnnotaion<!>(IMPLICIT_INT)
}
@@ -55,7 +55,7 @@ fun test() {
takeUBytes(IMPLICIT_INT, EXPLICIT_INT, 42u)
takeLong(<!NI;TYPE_MISMATCH!>IMPLICIT_INT<!>)
takeLong(<!TYPE_MISMATCH{NI}!>IMPLICIT_INT<!>)
takeIntWithoutAnnotation(IMPLICIT_INT)
@@ -63,7 +63,7 @@ fun test() {
takeUByte(<!TYPE_MISMATCH!>LONG_CONST<!>)
takeUByte(<!TYPE_MISMATCH!>NON_CONST<!>)
takeUByte(<!NI;TYPE_MISMATCH, TYPE_MISMATCH!>BIGGER_THAN_UBYTE<!>)
takeUByte(<!TYPE_MISMATCH{NI}, TYPE_MISMATCH!>BIGGER_THAN_UBYTE<!>)
takeUByte(<!TYPE_MISMATCH!>UINT_CONST<!>)
takeUIntWithoutAnnotaion(<!TYPE_MISMATCH!>IMPLICIT_INT<!>)
}
}
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE
// !CHECK_TYPE
// !WITH_NEW_INFERENCE
// Here we mostly trying to fix behaviour in order to track changes in inference rules for unsigned types later
fun <T> id(x: T): T = x
fun <K> select(x: K, y: K): K = TODO()
fun takeUByte(u: UByte) {}
fun foo() {
select(1, 1u) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Comparable<*>>() }
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(id(1))
1 <!NONE_APPLICABLE!>+<!> 1u
(1u <!NONE_APPLICABLE!>+<!> 1) <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><UInt>() }
<!INAPPLICABLE_CANDIDATE!>id<!><UInt>(1)
}
@@ -10,11 +10,11 @@ fun <K> select(x: K, y: K): K = TODO()
fun takeUByte(u: UByte) {}
fun foo() {
<!NI;TYPE_MISMATCH!>select<!>(1, 1u) checkType { <!NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Comparable<*>>() }
takeUByte(<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>id(1)<!>)
<!TYPE_MISMATCH{NI}!>select<!>(1, 1u) checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER{NI}!>_<!><Comparable<*>>() }
takeUByte(<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}!>id(1)<!>)
1 <!NONE_APPLICABLE!>+<!> 1u
(1u + <!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>) checkType { _<UInt>() }
id<UInt>(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>)
}
}
@@ -0,0 +1,14 @@
fun UInt.fUInt() {}
fun UByte.fUByte() {}
fun UShort.fUShort() {}
fun ULong.fULong() {}
fun test() {
1.<!INAPPLICABLE_CANDIDATE!>fUInt<!>()
1.<!INAPPLICABLE_CANDIDATE!>fUByte<!>()
1.<!INAPPLICABLE_CANDIDATE!>fUShort<!>()
1.<!INAPPLICABLE_CANDIDATE!>fULong<!>()
3000000000 <!NONE_APPLICABLE!>until<!> 3000000004UL
0 <!NONE_APPLICABLE!>until<!> 10u
}
@@ -0,0 +1,35 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !CHECK_TYPE
fun foo(x: Int): Int = 0
fun foo(x: UInt): String = ""
fun foo(x: UByte): String = ""
fun foo(x: UShort): String = ""
fun foo(x: ULong): String = ""
fun fooByte(x: Byte): Int = 0
fun fooByte(x: UByte): String = ""
fun fooShort(x: Short): Int = 0
fun fooShort(x: UShort): String = ""
fun fooLong(x: Long): Int = 0
fun fooLong(x: ULong): String = ""
fun test() {
foo(1) checkType { _<Int>() }
foo(1u) checkType { _<String>() }
<!NONE_APPLICABLE!>foo<!>(2147483648) <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
foo(2147483647 + 1) checkType { _<Int>() }
fooByte(1) checkType { _<Int>() }
fooByte(1u) checkType { _<String>() }
fooShort(1) checkType { _<Int>() }
fooShort(1u) checkType { _<String>() }
fooLong(1) checkType { _<Int>() }
fooLong(1u) checkType { _<String>() }
}
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !WITH_NEW_INFERENCE
fun takeUByte(u: UByte) {}
fun takeUShort(u: UShort) {}
fun takeUInt(u: UInt) {}
fun takeULong(u: ULong) {}
fun takeUBytes(vararg u: UByte) {}
fun takeNullableUInt(u: UInt?) {}
fun test() {
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(1 + 2)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(1.plus(2))
<!INAPPLICABLE_CANDIDATE!>takeNullableUInt<!>(4)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(Int.MAX_VALUE * 2L)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(-1)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(Int.MAX_VALUE * 2L + 2)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(1)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(255)
<!INAPPLICABLE_CANDIDATE!>takeUByte<!>(1.toByte())
<!INAPPLICABLE_CANDIDATE!>takeUShort<!>(1)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(1)
<!INAPPLICABLE_CANDIDATE!>takeULong<!>(1)
takeULong(<!ILLEGAL_CONST_EXPRESSION!>18446744073709551615<!>)
<!INAPPLICABLE_CANDIDATE!>takeULong<!>(1844674407370955161)
takeULong(18446744073709551615u)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(Int.MAX_VALUE * 2)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(4294967294)
<!INAPPLICABLE_CANDIDATE!>takeUBytes<!>(1, 2, 255, 256, 0, -1, 40 + 2)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(1.myPlus(2))
val localVariable = 42
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(localVariable)
var localMutableVariable = 42
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(localMutableVariable)
val localNegativeVariable = -1
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(localNegativeVariable)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(globalVariable)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(constVal)
<!INAPPLICABLE_CANDIDATE!>takeUInt<!>(globalVariableWithGetter)
}
val globalVariable = 10
const val constVal = 10
val globalVariableWithGetter: Int get() = 0
val prop: UByte = 255
fun Int.myPlus(other: Int): Int = this + other
@@ -27,7 +27,7 @@ fun test() {
takeUInt(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>)
takeULong(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1<!>)
takeULong(<!INT_LITERAL_OUT_OF_RANGE, NI;TYPE_MISMATCH!>18446744073709551615<!>)
takeULong(<!INT_LITERAL_OUT_OF_RANGE, TYPE_MISMATCH{NI}!>18446744073709551615<!>)
takeULong(<!SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED!>1844674407370955161<!>)
takeULong(18446744073709551615u)
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a0: Int = 1uL
val a1: UInt = 1uL
val a3: ULong = 1uL
val a4 = 1UL + 2UL
val a5 = <!UNRESOLVED_REFERENCE!>-<!>1UL
fun takeULong(u: ULong) {}
fun test() {
takeULong(3UL)
takeULong(1UL + 3uL)
takeULong(1u + 0uL)
takeULong(1uL + 4u)
}
@@ -13,4 +13,4 @@ fun test() {
takeULong(1UL + 3uL)
takeULong(1u + 0uL)
takeULong(1uL + 4u)
}
}
@@ -0,0 +1,23 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
fun test(
ub1: UByte, ub2: UByte,
us1: UShort, us2: UShort,
ui1: UInt, ui2: UInt,
ul1: ULong, ul2: ULong
) {
val ub = ub1 === ub2 || ub1 !== ub2
val us = us1 === us2 || us1 !== us2
val ui = ui1 === ui2 || ui1 !== ui2
val ul = ul1 === ul2 || ul1 !== ul2
val u = ub1 === ul1
val a1 = 1u === 2u || 1u !== 2u
val a2 = 0xFFFF_FFFF_FFFF_FFFFu === 0xFFFF_FFFF_FFFF_FFFFu
val bu1 = 1u
val bu2 = 1u
val c1 = bu1 === bu2 || bu1 !== bu2
}
@@ -0,0 +1,9 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
lateinit var a: UInt
fun foo() {
lateinit var b: UByte
lateinit var c: UShort
lateinit var d: ULong
}
@@ -0,0 +1,6 @@
// !API_VERSION: 1.2
val a = 0u
val b = 1uL
fun foo(u: UInt) {}
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
const val u1: UByte = 0xFFu
const val u2: UShort = 0xFFFFu
const val u3: UInt = 0xFFFF_FFFFu
const val u4: ULong = 0xFFFF_FFFF_FFFF_FFFFu
const val u5: ULong = 18446744073709551615u
const val u6 = 0xFFFF_FFFF_FFFF_FFFFu
const val u7 = 18446744073709551615u
val u8: Comparable<*> = 0xFFFF_FFFF_FFFF_FFFFu
const val u9 = 0xFFFF_FFFF_FFFF_FFFFUL
fun takeUByte(ubyte: UByte) {}
fun test() {
takeUByte(200u)
takeUByte(255u)
takeUByte(0xFFu)
}
val s1: UByte = 256u
val s2 = <!ILLEGAL_CONST_EXPRESSION!>18446744073709551616u<!>
@@ -22,4 +22,4 @@ fun test() {
}
val s1: UByte = <!CONSTANT_EXPECTED_TYPE_MISMATCH!>256u<!>
val s2 = <!INT_LITERAL_OUT_OF_RANGE!>18446744073709551616u<!>
val s2 = <!INT_LITERAL_OUT_OF_RANGE!>18446744073709551616u<!>
@@ -0,0 +1,23 @@
val a0: Any = 1u
val n0: Number = 1u
val c0: Comparable<*> = 1u
val c1: Comparable<UInt> = 1u
val u0: UInt = 1u
val u1: UInt? = 1u
val u2: UInt? = u0
val u3: UInt? = u1
val i0: Int = 1u
val m0 = <!UNRESOLVED_REFERENCE!>-<!>1u
val m1: UInt = <!UNRESOLVED_REFERENCE!>-<!>1u
val h1 = 0xFFu
val h2: UShort = 0xFFu
val b1 = 0b11u
val b2: UByte = 0b11u
@@ -20,4 +20,4 @@ val h1 = 0xFFu
val h2: UShort = 0xFFu
val b1 = 0b11u
val b2: UByte = 0b11u
val b2: UByte = 0b11u
@@ -0,0 +1,7 @@
fun ubyte(vararg a: UByte): UByteArray = a
fun ushort(vararg a: UShort): UShortArray = a
fun uint(vararg a: UInt): UIntArray = a
fun ulong(vararg a: ULong): ULongArray = a
fun rawUInt(vararg a: UInt): IntArray = a
@@ -0,0 +1,4 @@
val a1 = 1ul
val a2 = 0x1ul
val a3 = 0B1ul
val a4 = 1Ul
@@ -29280,6 +29280,128 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/unsignedTypes")
@TestDataPath("$PROJECT_ROOT")
public class UnsignedTypes extends AbstractDiagnosticTest {
@Test
public void testAllFilesPresentInUnsignedTypes() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/unsignedTypes"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("allowedVarargsOfUnsignedTypes.kt")
public void testAllowedVarargsOfUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.kt");
}
@Test
@TestMetadata("callDefaultConstructorOfUnsignedType.kt")
public void testCallDefaultConstructorOfUnsignedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/callDefaultConstructorOfUnsignedType.kt");
}
@Test
@TestMetadata("explicitUnsignedLongTypeCheck.kt")
public void testExplicitUnsignedLongTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/explicitUnsignedLongTypeCheck.kt");
}
@Test
@TestMetadata("forbiddenEqualsOnUnsignedTypes.kt")
public void testForbiddenEqualsOnUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/forbiddenEqualsOnUnsignedTypes.kt");
}
@Test
@TestMetadata("lateinitUnsignedType.kt")
public void testLateinitUnsignedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
}
@Test
@TestMetadata("overloadResolutionOfBasicOperations.kt")
public void testOverloadResolutionOfBasicOperations() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/overloadResolutionOfBasicOperations.kt");
}
@Test
@TestMetadata("unsignedLiteralsInsideConstVals.kt")
public void testUnsignedLiteralsInsideConstVals() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsInsideConstVals.kt");
}
@Test
@TestMetadata("unsignedLiteralsOn1_2.kt")
public void testUnsignedLiteralsOn1_2() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOn1_2.kt");
}
@Test
@TestMetadata("unsignedLiteralsOverflowSignedBorder.kt")
public void testUnsignedLiteralsOverflowSignedBorder() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOverflowSignedBorder.kt");
}
@Test
@TestMetadata("unsignedLiteralsTypeCheck.kt")
public void testUnsignedLiteralsTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsTypeCheck.kt");
}
@Test
@TestMetadata("varargTypeToArrayTypeCheck.kt")
public void testVarargTypeToArrayTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/varargTypeToArrayTypeCheck.kt");
}
@Test
@TestMetadata("wrongLongSuffixForULong.kt")
public void testWrongLongSuffixForULong() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/wrongLongSuffixForULong.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/unsignedTypes/conversions")
@TestDataPath("$PROJECT_ROOT")
public class Conversions extends AbstractDiagnosticTest {
@Test
public void testAllFilesPresentInConversions() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/unsignedTypes/conversions"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("conversionOfSignedToUnsigned.kt")
public void testConversionOfSignedToUnsigned() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/conversionOfSignedToUnsigned.kt");
}
@Test
@TestMetadata("inferenceForSignedAndUnsignedTypes.kt")
public void testInferenceForSignedAndUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.kt");
}
@Test
@TestMetadata("noConversionForUnsignedTypesOnReceiver.kt")
public void testNoConversionForUnsignedTypesOnReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt");
}
@Test
@TestMetadata("overloadResolutionForSignedAndUnsignedTypes.kt")
public void testOverloadResolutionForSignedAndUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/overloadResolutionForSignedAndUnsignedTypes.kt");
}
@Test
@TestMetadata("signedToUnsignedConversionWithExpectedType.kt")
public void testSignedToUnsignedConversionWithExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt");
}
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/valueClasses")
@TestDataPath("$PROJECT_ROOT")
@@ -29184,6 +29184,128 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/unsignedTypes")
@TestDataPath("$PROJECT_ROOT")
public class UnsignedTypes extends AbstractFirDiagnosticTest {
@Test
public void testAllFilesPresentInUnsignedTypes() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/unsignedTypes"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("allowedVarargsOfUnsignedTypes.kt")
public void testAllowedVarargsOfUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/allowedVarargsOfUnsignedTypes.kt");
}
@Test
@TestMetadata("callDefaultConstructorOfUnsignedType.kt")
public void testCallDefaultConstructorOfUnsignedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/callDefaultConstructorOfUnsignedType.kt");
}
@Test
@TestMetadata("explicitUnsignedLongTypeCheck.kt")
public void testExplicitUnsignedLongTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/explicitUnsignedLongTypeCheck.kt");
}
@Test
@TestMetadata("forbiddenEqualsOnUnsignedTypes.kt")
public void testForbiddenEqualsOnUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/forbiddenEqualsOnUnsignedTypes.kt");
}
@Test
@TestMetadata("lateinitUnsignedType.kt")
public void testLateinitUnsignedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
}
@Test
@TestMetadata("overloadResolutionOfBasicOperations.kt")
public void testOverloadResolutionOfBasicOperations() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/overloadResolutionOfBasicOperations.kt");
}
@Test
@TestMetadata("unsignedLiteralsInsideConstVals.kt")
public void testUnsignedLiteralsInsideConstVals() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsInsideConstVals.kt");
}
@Test
@TestMetadata("unsignedLiteralsOn1_2.kt")
public void testUnsignedLiteralsOn1_2() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOn1_2.kt");
}
@Test
@TestMetadata("unsignedLiteralsOverflowSignedBorder.kt")
public void testUnsignedLiteralsOverflowSignedBorder() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsOverflowSignedBorder.kt");
}
@Test
@TestMetadata("unsignedLiteralsTypeCheck.kt")
public void testUnsignedLiteralsTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/unsignedLiteralsTypeCheck.kt");
}
@Test
@TestMetadata("varargTypeToArrayTypeCheck.kt")
public void testVarargTypeToArrayTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/varargTypeToArrayTypeCheck.kt");
}
@Test
@TestMetadata("wrongLongSuffixForULong.kt")
public void testWrongLongSuffixForULong() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/wrongLongSuffixForULong.kt");
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/unsignedTypes/conversions")
@TestDataPath("$PROJECT_ROOT")
public class Conversions extends AbstractFirDiagnosticTest {
@Test
public void testAllFilesPresentInConversions() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/unsignedTypes/conversions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("conversionOfSignedToUnsigned.kt")
public void testConversionOfSignedToUnsigned() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/conversionOfSignedToUnsigned.kt");
}
@Test
@TestMetadata("inferenceForSignedAndUnsignedTypes.kt")
public void testInferenceForSignedAndUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.kt");
}
@Test
@TestMetadata("noConversionForUnsignedTypesOnReceiver.kt")
public void testNoConversionForUnsignedTypesOnReceiver() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt");
}
@Test
@TestMetadata("overloadResolutionForSignedAndUnsignedTypes.kt")
public void testOverloadResolutionForSignedAndUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/overloadResolutionForSignedAndUnsignedTypes.kt");
}
@Test
@TestMetadata("signedToUnsignedConversionWithExpectedType.kt")
public void testSignedToUnsignedConversionWithExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/unsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt");
}
}
}
@Nested
@TestMetadata("compiler/testData/diagnostics/tests/valueClasses")
@TestDataPath("$PROJECT_ROOT")
@@ -10,8 +10,8 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_PSI_CLASS_FILES_READING
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.WITH_STDLIB
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.EXPLICIT_API_MODE
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives.USE_EXPERIMENTAL
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicDiagnosticsHandler
import org.jetbrains.kotlin.test.frontend.classic.handlers.DeclarationsDumpHandler
@@ -70,5 +70,12 @@ abstract class AbstractDiagnosticTest : AbstractKotlinCompilerTest() {
EXPLICIT_API_MODE with ExplicitApiMode.STRICT
}
}
forTestsMatching("compiler/testData/diagnostics/tests/unsignedTypes/*") {
defaultDirectives {
USE_EXPERIMENTAL with "kotlin.ExperimentalUnsignedTypes"
+WITH_STDLIB
}
}
}
}
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
import org.jetbrains.kotlin.test.frontend.fir.FirFailingTestSuppressor
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
import org.jetbrains.kotlin.test.frontend.fir.handlers.*
@@ -60,7 +61,8 @@ abstract class AbstractFirDiagnosticTest : AbstractKotlinCompilerTest() {
forTestsMatching(
"compiler/testData/diagnostics/testsWithStdLib/*" or
"compiler/fir/analysis-tests/testData/resolveWithStdlib/*"
"compiler/fir/analysis-tests/testData/resolveWithStdlib/*" or
"compiler/testData/diagnostics/tests/unsignedTypes/*"
) {
defaultDirectives {
+JvmEnvironmentConfigurationDirectives.WITH_STDLIB
@@ -1,27 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.ApiVersion
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.test.ConfigurationKind
abstract class AbstractDiagnosticsWithUnsignedTypes : AbstractDiagnosticsTest() {
override fun extractConfigurationKind(files: List<TestFile>): ConfigurationKind {
return ConfigurationKind.NO_KOTLIN_REFLECT
}
override fun defaultLanguageVersionSettings(): LanguageVersionSettings =
CompilerTestLanguageVersionSettings(
DEFAULT_DIAGNOSTIC_TESTS_FEATURES,
ApiVersion.LATEST_STABLE,
LanguageVersion.LATEST_STABLE,
mapOf(AnalysisFlags.useExperimental to listOf("kotlin.ExperimentalUnsignedTypes"))
)
}
@@ -1,128 +0,0 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.checkers;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/diagnostics/testsWithUnsignedTypes")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class DiagnosticsWithUnsignedTypesGenerated extends AbstractDiagnosticsWithUnsignedTypes {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInTestsWithUnsignedTypes() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithUnsignedTypes"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("allowedVarargsOfUnsignedTypes.kt")
public void testAllowedVarargsOfUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/allowedVarargsOfUnsignedTypes.kt");
}
@TestMetadata("callDefaultConstructorOfUnsignedType.kt")
public void testCallDefaultConstructorOfUnsignedType() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/callDefaultConstructorOfUnsignedType.kt");
}
@TestMetadata("explicitUnsignedLongTypeCheck.kt")
public void testExplicitUnsignedLongTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/explicitUnsignedLongTypeCheck.kt");
}
@TestMetadata("forbiddenEqualsOnUnsignedTypes.kt")
public void testForbiddenEqualsOnUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/forbiddenEqualsOnUnsignedTypes.kt");
}
@TestMetadata("lateinitUnsignedType.kt")
public void testLateinitUnsignedType() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/lateinitUnsignedType.kt");
}
@TestMetadata("overloadResolutionOfBasicOperations.kt")
public void testOverloadResolutionOfBasicOperations() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/overloadResolutionOfBasicOperations.kt");
}
@TestMetadata("unsignedLiteralsInsideConstVals.kt")
public void testUnsignedLiteralsInsideConstVals() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/unsignedLiteralsInsideConstVals.kt");
}
@TestMetadata("unsignedLiteralsOn1_2.kt")
public void testUnsignedLiteralsOn1_2() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/unsignedLiteralsOn1_2.kt");
}
@TestMetadata("unsignedLiteralsOverflowSignedBorder.kt")
public void testUnsignedLiteralsOverflowSignedBorder() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/unsignedLiteralsOverflowSignedBorder.kt");
}
@TestMetadata("unsignedLiteralsTypeCheck.kt")
public void testUnsignedLiteralsTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/unsignedLiteralsTypeCheck.kt");
}
@TestMetadata("varargTypeToArrayTypeCheck.kt")
public void testVarargTypeToArrayTypeCheck() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/varargTypeToArrayTypeCheck.kt");
}
@TestMetadata("wrongLongSuffixForULong.kt")
public void testWrongLongSuffixForULong() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/wrongLongSuffixForULong.kt");
}
@TestMetadata("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Conversions extends AbstractDiagnosticsWithUnsignedTypes {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInConversions() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("conversionOfSignedToUnsigned.kt")
public void testConversionOfSignedToUnsigned() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/conversionOfSignedToUnsigned.kt");
}
@TestMetadata("inferenceForSignedAndUnsignedTypes.kt")
public void testInferenceForSignedAndUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/inferenceForSignedAndUnsignedTypes.kt");
}
@TestMetadata("noConversionForUnsignedTypesOnReceiver.kt")
public void testNoConversionForUnsignedTypesOnReceiver() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/noConversionForUnsignedTypesOnReceiver.kt");
}
@TestMetadata("overloadResolutionForSignedAndUnsignedTypes.kt")
public void testOverloadResolutionForSignedAndUnsignedTypes() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/overloadResolutionForSignedAndUnsignedTypes.kt");
}
@TestMetadata("signedToUnsignedConversionWithExpectedType.kt")
public void testSignedToUnsignedConversionWithExpectedType() throws Exception {
runTest("compiler/testData/diagnostics/testsWithUnsignedTypes/conversions/signedToUnsignedConversionWithExpectedType.kt");
}
}
}
@@ -88,10 +88,6 @@ fun main(args: Array<String>) {
model("diagnostics/testsWithJava15")
}
testClass<AbstractDiagnosticsWithUnsignedTypes> {
model("diagnostics/testsWithUnsignedTypes")
}
testClass<AbstractDiagnosticsTestWithOldJvmBackend> {
model("diagnostics/testsWithJvmBackend", targetBackend = TargetBackend.JVM_OLD)
}