Add 'not linked' kind of spec tests

This commit is contained in:
victor.petukhov
2018-08-28 19:06:59 +03:00
parent 841bb4f253
commit ecf8b88c4c
72 changed files with 1140 additions and 928 deletions
+31 -30
View File
@@ -9,13 +9,13 @@ Note: diagnostic tests format specification you can see in the [diagnostic tests
Each test relates to a specific section, paragraph, and sentence of the Kotlin language specification, and is either positive or negative.
The folder structure is as follows:
* `s-<sectionNumber>_<sectionName>`
* `<sectionName>`
* `p-<paragraphNumber>`
* `<neg|pos>`
* `<setenceNumber>.<testNumber>.kt` (test source code)
* `<setenceNumber>.<testNumber>.txt` (descriptors file)
Example test file path: `testsSpec/s-16.30_when-expression/p-2/neg/3.1.kt`
Example test file path: `testData/diagnostics/linked/when-expression/p-2/neg/3.1.kt`
## Positive and negative tests
@@ -35,9 +35,9 @@ A comment with meta information has the following format:
/*
KOTLIN SPEC TEST (<POSITIVE|NEGATIVE>)
SECTION <sectionNumber>: <sectionName>
SECTION: <sectionName>
PARAGRAPH: <paragraphNumber>
SENTENCE <setenceNumber>: <setence>
SENTENCE: [<setenceNumber>] <setence>
NUMBER: <testNumber>
DESCRIPTION: <testDescription>
*/
@@ -45,17 +45,17 @@ A comment with meta information has the following format:
Example:
```
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION 16.30: When expression
PARAGRAPH: 3
SENTENCE 2: Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
SECTION: when-expression
PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 1
DESCRIPTION: 'When' with not boolean condition in 'when condition'
DESCRIPTION: Empty 'when' with bound value.
*/
```
Meta-information should be placed at the beginning of the file after diagnostic directives (if any).
Meta-information should be placed at the beginning of the file after directives (if any).
### Case description
@@ -92,23 +92,23 @@ If the validation fails, you will receive exception about it.
During the test run, the following information is displayed for each test:
```
<POSITIVE|NEGATIVE> DIAGNOSTICS SPEC TEST
SECTION: <sectionNumber> <sectionName> (paragraph: <paragraphNumber>)
SENTENCE <sentenceNumber> [<specUrl>]: <sentence>
DIAGNOSTICS <POSITIVE|NEGATIVE> SPEC TEST
SECTION: <sectionName> (paragraph: <paragraphNumber>)
SENTENCE <sentenceNumber>: <sentence>
TEST NUMBER: <testNumber>
NUMBER OF TEST CASES: <casesNumber>
TEST CASES: <casesNumber>
DESCRIPTION: <testDescription>
DIAGNOSTICS: <diagnosticSeverities> | <diagnostics>
```
Example:
```
POSITIVE DIAGNOSTICS SPEC TEST
SECTION: 16.30 When expression (paragraph: 5)
SENTENCE 1 [http://jetbrains.github.io/kotlin-spec/#when-expression:5:1]: The type of the resulting expression is the least upper bound of the types of all the entries.
TEST NUMBER: 4
NUMBER OF TEST CASES: 9
DESCRIPTION: 'When' least upper bound of the types check (when exhaustive via sealed class).
DIAGNOSTICS: {WARNING=15} | {USELESS_IS_CHECK=1, IMPLICIT_CAST_TO_ANY=14}
DIAGNOSTICS NEGATIVE SPEC TEST
SECTION: when-expression (paragraph: 3)
SENTENCE 1:
TEST NUMBER: 1
NUMBER OF TEST CASES: 3
DESCRIPTION: 'When' without bound value and not allowed break and continue expression (without labels) in the control structure body.
DIAGNOSTICS: {ERROR=2, WARNING=1} | {BREAK_OR_CONTINUE_IN_WHEN=2, UNREACHABLE_CODE=1}
```
## Statistics on specification tests
@@ -118,18 +118,19 @@ To see statistics for existing tests you can run gradle task `printSpecTestStati
Example output:
```
--------------------------------------------------
==================================================
SPEC TESTS STATISTIC
--------------------------------------------------
DIAGNOSTICS: 131 tests
16.30 WHEN-EXPRESSION: 131 tests
PARAGRAPH 2: 4 tests (neg: 2, pos: 2)
PARAGRAPH 3: 35 tests (neg: 5, pos: 30)
PARAGRAPH 4: 67 tests (neg: 11, pos: 56)
PARAGRAPH 5: 8 tests (neg: 4, pos: 4)
PARAGRAPH 6: 17 tests (neg: 8, pos: 9)
PSI: 0 tests
DIAGNOSTICS: 54 tests
when-expression: 54 tests
PARAGRAPH 9: 8 tests [ neg: 4 ] [ pos: 4 ]
PARAGRAPH 7: 16 tests [ neg: 7 ] [ pos: 9 ]
PARAGRAPH 6: 2 tests [ neg: 1 ] [ pos: 1 ]
PARAGRAPH 11: 17 tests [ neg: 8 ] [ pos: 9 ]
PARAGRAPH 3: 7 tests [ neg: 3 ] [ pos: 4 ]
PARAGRAPH 2: 2 tests [ pos: 2 ]
PARAGRAPH 5: 2 tests [ neg: 1 ] [ pos: 1 ]
CODEGEN: 0 tests
--------------------------------------------------
```
@@ -4,16 +4,16 @@ class _Class {
val prop_3 = 3
fun fun_1(): (Int) -> (Int) -> Int = {number: Int -> { number * 5 }}
fun fun_2(value: Int): Int = value * 2
fun fun_3(value1: Int): (Int) -> Int = fun(value2: Int): Int = value1 * value2 * 2
fun fun_2(value_1: Int): Int = value_1 * 2
fun fun_3(value_1: Int): (Int) -> Int = fun(value_2: Int): Int = value_1 * value_2 * 2
operator fun contains(a: Int): Boolean = a > 30
operator fun contains(a: Long): Boolean = a > 30L
operator fun contains(a: Char): Boolean = a > 30.toChar()
fun getIntArray(value: Int): IntArray = intArrayOf(1, 2, 3, value, 91923, 14, 123124)
fun getLongArray(value: Long): LongArray = longArrayOf(1L, 2L, 3L, value, 9192323244L, 14L, 123124L)
fun getCharArray(value: Char): CharArray = charArrayOf(1.toChar(), 2.toChar(), 3.toChar(), value)
fun getIntArray(value_1: Int): IntArray = intArrayOf(1, 2, 3, value_1, 91923, 14, 123124)
fun getLongArray(value_1: Long): LongArray = longArrayOf(1L, 2L, 3L, value_1, 9192323244L, 14L, 123124L)
fun getCharArray(value_1: Char): CharArray = charArrayOf(1.toChar(), 2.toChar(), 3.toChar(), value_1)
class _NestedClass {
val prop_4 = 4
@@ -0,0 +1,7 @@
fun _funWithoutArgs(): Int {
return Any().hashCode().toInt()
}
fun _funWithAnyArg(value_1: Any): Int {
return value_1.hashCode()
}
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 2
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression;
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 2
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 3
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 2
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [1] It has an else entry;
NUMBER: 3
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When valueession
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession;
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 2
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 3
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 1
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 2
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 2
@@ -1,12 +1,12 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -DEBUG_INFO_SMARTCAST
// !WITH_BASIC_TYPES
// !WITH_CLASSES
// !WITH_FUNS
// !WITH_FUNCTIONS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
NUMBER: 1
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 1
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 2
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 3
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 5
SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
NUMBER: 1
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 5
SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
NUMBER: 1
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 6
SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
NUMBER: 1
@@ -1,12 +1,12 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
// !WITH_BASIC_TYPES
// !WITH_FUNS
// !WITH_FUNCTIONS
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 6
SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 1
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 2
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 3
@@ -3,7 +3,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 4
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2
@@ -1,11 +1,11 @@
// !WITH_BASIC_TYPES
// !WITH_FUNS
// !WITH_FUNCTIONS
// !WITH_CLASSES
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 1
@@ -1,11 +1,11 @@
// !WITH_BASIC_TYPES
// !WITH_CLASSES
// !WITH_FUNS
// !WITH_FUNCTIONS
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [5] Any other expression.
NUMBER: 2
@@ -1,7 +1,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 1
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 2
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 3
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 4
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 1
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 2
@@ -4,7 +4,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 3
@@ -5,7 +5,7 @@
/*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: 16.30 When expression
SECTION: when-expression
PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 4
@@ -1,3 +0,0 @@
fun _funWithoutArgs(): Int {
return Any().hashCode().toInt()
}
@@ -9,8 +9,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.spec.DiagnosticSpecTestValidator
import org.jetbrains.kotlin.spec.SpecTestValidationException
import org.jetbrains.kotlin.spec.validators.*
import org.jetbrains.kotlin.test.*
import org.junit.Assert
import java.io.File
@@ -19,38 +18,50 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() {
companion object {
// map of pairs: source helper filename - target helper filename
private val directives = mapOf(
"WITH_BASIC_TYPES" to Pair("basicTypes.kt", "BASIC_TYPES.kt"),
"WITH_CLASSES" to Pair("classes.kt", "CLASSES.kt"),
"WITH_ENUM_CLASSES" to Pair("enumClasses.kt", "ENUM_CLASSES.kt"),
"WITH_SEALED_CLASSES" to Pair("sealedClasses.kt", "SEALED_CLASSES.kt"),
"WITH_FUNS" to Pair("funs.kt", "FUNS.kt"),
"WITH_OBJECTS" to Pair("objects.kt", "OBJECTS.kt"),
"WITH_TYPEALIASES" to Pair("typeAliases.kt", "TYPE_ALIASES.kt")
"WITH_BASIC_TYPES" to "basicTypes.kt",
"WITH_CLASSES" to "classes.kt",
"WITH_ENUM_CLASSES" to "enumClasses.kt",
"WITH_SEALED_CLASSES" to "sealedClasses.kt",
"WITH_FUNCTIONS" to "functions.kt",
"WITH_OBJECTS" to "objects.kt",
"WITH_TYPEALIASES" to "typeAliases.kt",
"WITH_CONTRACT_FUNCTIONS" to "contractFunctions.kt"
)
private const val MODULE_PATH = "./compiler/tests-spec"
private const val HELPERS_PATH = "$MODULE_PATH/testData/helpers/diagnostics"
private val withoutDescriptorsTestGroups = listOf(
"linked/when-expression"
)
private const val MODULE_PATH = "compiler/tests-spec"
private const val DIAGNOSTICS_TESTDATA_PATH = "$MODULE_PATH/testData/diagnostics"
private const val HELPERS_PATH = "$DIAGNOSTICS_TESTDATA_PATH/helpers"
}
private lateinit var testValidator: DiagnosticSpecTestValidator
private lateinit var testValidator: AbstractSpecTestValidator<out AbstractSpecTest>
private var skipDescriptors = true
private fun checkDirective(directive: String, testFiles: List<TestFile>) =
testFiles.any { it.directives.contains(directive) }
private fun enableDescriptorsGenerationIfNeeded(testDataFile: File) {
skipDescriptors = withoutDescriptorsTestGroups.any {
val testGroupAbsolutePath = File("$DIAGNOSTICS_TESTDATA_PATH/$it").absolutePath
testDataFile.absolutePath.startsWith(testGroupAbsolutePath)
}
}
override fun getConfigurationKind() = ConfigurationKind.ALL
override fun skipDescriptorsValidation(): Boolean = true
override fun skipDescriptorsValidation() = skipDescriptors
override fun getKtFiles(testFiles: List<TestFile>, includeExtras: Boolean): List<KtFile> {
val ktFiles = super.getKtFiles(testFiles, includeExtras) as ArrayList
if (includeExtras) {
for ((name, filenames) in directives) {
for ((name, filename) in directives) {
if (checkDirective(name, testFiles)) {
val (sourceFilename, targetFilename) = filenames
val declarations = File("$HELPERS_PATH/$sourceFilename").readText()
ktFiles.add(KotlinTestUtils.createFile(targetFilename, declarations, project))
val declarations = File("$HELPERS_PATH/$filename").readText()
ktFiles.add(KotlinTestUtils.createFile(filename, declarations, project))
}
}
}
@@ -59,7 +70,9 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() {
}
override fun analyzeAndCheck(testDataFile: File, files: List<TestFile>) {
testValidator = DiagnosticSpecTestValidator(testDataFile)
enableDescriptorsGenerationIfNeeded(testDataFile)
testValidator = AbstractSpecTestValidator.getInstanceByType(testDataFile)
try {
testValidator.parseTestInfo()
@@ -80,12 +93,13 @@ abstract class AbstractDiagnosticsTestSpec : AbstractDiagnosticsTest() {
moduleBindings: Map<TestModule?, BindingContext>,
languageVersionSettingsByModule: Map<TestModule?, LanguageVersionSettings>
) {
val diagnosticValidator = DiagnosticTestTypeValidator(testFiles)
try {
testValidator.validateTestType(testFiles)
testValidator.validateTestType(computedTestType = diagnosticValidator.computeTestType())
} catch (e: SpecTestValidationException) {
Assert.fail(e.description)
} finally {
testValidator.printDiagnosticStatistic()
diagnosticValidator.printDiagnosticStatistic()
}
}
}
@@ -26,547 +26,560 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
}
public void testAllFilesPresentInDiagnostics() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true, "helpers");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class S_16_30_when_expression extends AbstractDiagnosticsTestSpec {
public static class Linked extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInS_16_30_when_expression() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
public void testAllFilesPresentInLinked() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_11 extends AbstractDiagnosticsTestSpec {
public static class When_expression extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInP_11() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
public void testAllFilesPresentInWhen_expression() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
public static class P_11 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/1.1.kt");
public void testAllFilesPresentInP_11() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/1.2.kt");
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/1.2.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/3.1.kt");
}
@TestMetadata("6.1.kt")
public void test6_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/6.1.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/7.1.kt");
}
@TestMetadata("8.1.kt")
public void test8_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.1.kt");
}
@TestMetadata("8.2.kt")
public void test8_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.2.kt");
}
@TestMetadata("8.3.kt")
public void test8_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg/8.3.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/3.1.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("6.1.kt")
public void test6_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/6.1.kt");
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.1.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/7.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.2.kt");
}
@TestMetadata("8.1.kt")
public void test8_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/8.1.kt");
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/1.3.kt");
}
@TestMetadata("8.2.kt")
public void test8_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/8.2.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/3.1.kt");
}
@TestMetadata("8.3.kt")
public void test8_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg/8.3.kt");
}
@TestMetadata("6.1.kt")
public void test6_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/6.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/7.1.kt");
}
@TestMetadata("8.1.kt")
public void test8_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.1.kt");
}
@TestMetadata("8.2.kt")
public void test8_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.2.kt");
}
@TestMetadata("8.3.kt")
public void test8_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos/8.3.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-11/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
public static class P_2 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/1.1.kt");
public void testAllFilesPresentInP_2() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/1.2.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/1.3.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.1.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos/3.2.kt");
}
@TestMetadata("6.1.kt")
public void test6_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/6.1.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/7.1.kt");
}
@TestMetadata("8.1.kt")
public void test8_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/8.1.kt");
}
@TestMetadata("8.2.kt")
public void test8_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/8.2.kt");
}
@TestMetadata("8.3.kt")
public void test8_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos/8.3.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-11/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_2 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInP_2() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
public static class P_3 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos/3.1.kt");
public void testAllFilesPresentInP_3() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos/3.2.kt");
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/1.1.kt");
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.1.kt");
}
@TestMetadata("2.2.kt")
public void test2_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg/2.2.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/1.1.kt");
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.1.kt");
}
@TestMetadata("2.2.kt")
public void test2_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.2.kt");
}
@TestMetadata("2.3.kt")
public void test2_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos/2.3.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-3/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_3 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInP_3() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
public static class P_5 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg/1.1.kt");
public void testAllFilesPresentInP_5() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg/2.1.kt");
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg/1.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("2.2.kt")
public void test2_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg/2.2.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos/1.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
public static class P_6 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/1.1.kt");
public void testAllFilesPresentInP_6() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/2.1.kt");
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg/1.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("2.2.kt")
public void test2_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/2.2.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("2.3.kt")
public void test2_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos/2.3.kt");
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos/1.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-3/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-6/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_5 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInP_5() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/neg")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
public static class P_7 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/neg/1.1.kt");
public void testAllFilesPresentInP_7() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/1.2.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/3.2.kt");
}
@TestMetadata("5.1.kt")
public void test5_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.1.kt");
}
@TestMetadata("5.2.kt")
public void test5_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/5.2.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg/7.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.2.kt");
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.3.kt");
}
@TestMetadata("1.4.kt")
public void test1_4() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/1.4.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/3.2.kt");
}
@TestMetadata("5.1.kt")
public void test5_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.1.kt");
}
@TestMetadata("5.2.kt")
public void test5_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/5.2.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos/7.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-7/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/pos")
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
public static class P_9 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/pos/1.1.kt");
public void testAllFilesPresentInP_9() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_6 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.1.kt");
}
public void testAllFilesPresentInP_6() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.2.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.3.kt");
}
@TestMetadata("1.4.kt")
public void test1_4() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg/1.4.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/neg/1.1.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.1.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.2.kt");
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/pos/1.1.kt");
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.3.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-6/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("1.4.kt")
public void test1_4() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos/1.4.kt");
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_7 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInP_7() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/1.2.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/3.2.kt");
}
@TestMetadata("5.1.kt")
public void test5_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/5.1.kt");
}
@TestMetadata("5.2.kt")
public void test5_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/5.2.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg/7.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.2.kt");
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.3.kt");
}
@TestMetadata("1.4.kt")
public void test1_4() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/1.4.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/3.2.kt");
}
@TestMetadata("5.1.kt")
public void test5_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/5.1.kt");
}
@TestMetadata("5.2.kt")
public void test5_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/5.2.kt");
}
@TestMetadata("7.1.kt")
public void test7_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos/7.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-7/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_9 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInP_9() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.2.kt");
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.3.kt");
}
@TestMetadata("1.4.kt")
public void test1_4() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg/1.4.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/neg"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.1.kt");
}
@TestMetadata("1.2.kt")
public void test1_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.2.kt");
}
@TestMetadata("1.3.kt")
public void test1_3() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.3.kt");
}
@TestMetadata("1.4.kt")
public void test1_4() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos/1.4.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/s-16.30_when-expression/p-9/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/when-expression/p-9/pos"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
}
}
}
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTestSpec
fun main(args: Array<String>) {
testGroup("compiler/tests-spec/tests", "compiler/tests-spec/testData") {
testClass<AbstractDiagnosticsTestSpec> {
model("diagnostics")
model("diagnostics", excludeDirs = listOf("helpers"))
}
}
}
@@ -1,68 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.spec
import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Severity
import java.io.File
class DiagnosticSpecTestValidator(testDataFile: File) : SpecTestValidator(testDataFile, TestArea.DIAGNOSTICS) {
private lateinit var diagnostics: MutableList<Diagnostic>
private lateinit var diagnosticStats: MutableMap<String, Int>
private lateinit var diagnosticSeverityStats: MutableMap<Severity, Int>
private fun collectDiagnosticStatistic() {
diagnosticSeverityStats = mutableMapOf()
diagnostics.forEach {
val severity = it.factory.severity
if (diagnosticSeverityStats.contains(severity)) {
diagnosticSeverityStats[severity] = diagnosticSeverityStats[severity]!! + 1
} else {
diagnosticSeverityStats[severity] = 1
}
}
}
private fun computeTestType(): TestType {
return if (Severity.ERROR in diagnosticSeverityStats) TestType.NEGATIVE else TestType.POSITIVE
}
private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) {
diagnostics = mutableListOf()
diagnosticStats = mutableMapOf()
files.forEach {
it.actualDiagnostics.forEach {
val diagnosticName = it.diagnostic.factory.name
if (diagnosticStats.contains(diagnosticName)) {
diagnosticStats[diagnosticName] = diagnosticStats[diagnosticName]!! + 1
} else {
diagnosticStats[diagnosticName] = 1
}
diagnostics.add(it.diagnostic)
}
}
collectDiagnosticStatistic()
}
fun validateTestType(files: List<BaseDiagnosticsTest.TestFile>) {
if (!this::diagnostics.isInitialized) this.collectDiagnostics(files)
validateTestType(computeTestType())
}
fun printDiagnosticStatistic() {
val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain"
println("DIAGNOSTICS: $diagnostics")
}
}
@@ -1,323 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.spec
import java.io.File
import java.util.regex.Matcher
import java.util.regex.Pattern
enum class TestType(val type: String) {
POSITIVE("pos"),
NEGATIVE("neg");
companion object {
private val map = TestType.values().associateBy(TestType::type)
fun fromValue(type: String) = map[type]
}
}
enum class TestArea {
PSI,
DIAGNOSTICS,
CODEGEN
}
interface SpecTestInfoElementType {
val valuePattern: Pattern?
val required: Boolean
}
enum class SpecTestFileInfoElementType(
override val valuePattern: Pattern? = null,
override val required: Boolean = false
) : SpecTestInfoElementType {
SECTION(
valuePattern = Pattern.compile("""(?<number>(?:${SpecTestValidator.INTEGER_REGEX})(?:\.${SpecTestValidator.INTEGER_REGEX})*)(?<name>.*?)"""),
required = true
),
PARAGRAPH(required = true),
SENTENCE(
valuePattern = Pattern.compile("""\[(?<number>${SpecTestValidator.INTEGER_REGEX})\](?<text>.*?)"""),
required = true
),
NUMBER(required = true),
DESCRIPTION(required = true),
ISSUES(valuePattern = Pattern.compile("""(KT-[1-9]\d*)(,\s*KT-[1-9]\d*)*""")),
UNEXPECTED_BEHAVIOUR,
DISCUSSION,
NOTE
}
enum class SpecTestCaseInfoElementType(
override val valuePattern: Pattern? = null,
override val required: Boolean = false
) : SpecTestInfoElementType {
CASE_DESCRIPTION(required = true),
ISSUES(valuePattern = SpecTestFileInfoElementType.ISSUES.valuePattern),
UNEXPECTED_BEHAVIOUR,
DISCUSSION,
NOTE
}
data class SpecTestInfoElementContent(
val content: String,
val additionalMatcher: Matcher? = null
)
data class SpecTestCase(
val number: Int,
val description: String,
val unexpectedBehavior: Boolean,
val issues: List<String>?
)
class SpecTest(
val testArea: TestArea,
val testType: TestType,
val sectionNumber: String,
val sectionName: String,
val paragraphNumber: Int,
val sentenceNumber: Int,
val sentence: String? = null,
val testNumber: Int,
val description: String? = null,
val cases: List<SpecTestCase>? = null,
val unexpectedBehavior: Boolean? = null,
val issues: Set<String>? = null
) {
fun checkConsistency(other: SpecTest): Boolean {
return this.testArea == other.testArea
&& this.testType == other.testType
&& this.sectionNumber == other.sectionNumber
&& this.testNumber == other.testNumber
&& this.paragraphNumber == other.paragraphNumber
&& this.sentenceNumber == other.sentenceNumber
}
}
enum class SpecTestValidationFailedReason(val description: String) {
FILENAME_NOT_VALID(
"Incorrect test filename or folder name.${SpecTestValidator.lineSeparator}" +
"It must match the following path pattern: " +
"testsData/<diagnostic|psi|codegen>/s<sectionNumber>_<sectionName>/p-<paragraph>/<pos|neg>/<sentence>_<testNumber>.kt " +
"(example: testsData/diagnostic/s-16.30_when-expression/p-3/pos/1.3.kt)"
),
TESTINFO_NOT_VALID("Test info is incorrect."),
FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY("Test info from filepath and file content is not consistency"),
TEST_IS_NOT_POSITIVE("Test is not positive because it contains error elements (PsiErrorElement or diagnostic with error severity)."),
TEST_IS_NOT_NEGATIVE("Test is not negative because it not contains error type elements (PsiErrorElement or diagnostic with error severity)."),
UNKNOWN("Unknown validation error.")
}
class SpecTestValidationException(reason: SpecTestValidationFailedReason, details: String = "") : Exception() {
val description = "${reason.description} $details"
}
typealias SpecTestInfoElements<T> = Map<T, SpecTestInfoElementContent>
abstract class SpecTestValidator(private val testDataFile: File, private val testArea: TestArea) {
private lateinit var testInfoByFilename: SpecTest
private lateinit var testInfoByContent: SpecTest
private val testInfo by lazy { testInfoByContent }
companion object {
const val INTEGER_REGEX = """[1-9]\d*"""
private const val SINGLELINE_COMMENT_REGEX = """\/\/\s*%s"""
private const val MULTILINE_COMMENT_REGEX = """\/\*\s*%s\s+\*\/"""
val lineSeparator: String = System.lineSeparator()
private val testCaseInfoRegex = """(?<infoElements>CASE DESCRIPTION:[\s\S]*?$lineSeparator)"""
private val testAreaRegex = """(?<testArea>${TestArea.values().joinToString("|")})"""
private val testTypeRegex = """(?<testType>${TestType.values().joinToString("|")})"""
private val testInfoElementPattern: Pattern = Pattern.compile("""\s*(?<name>[A-Z ]*?):\s*(?<value>.*?)$lineSeparator""")
private val pathSeparator = Pattern.quote(File.separator)
val testPathPattern: Pattern =
Pattern.compile("""^.*?$pathSeparator(?<testArea>diagnostics|psi|codegen)${pathSeparator}s-(?<sectionNumber>(?:$INTEGER_REGEX)(?:\.$INTEGER_REGEX)*)_(?<sectionName>[\w-]+)${pathSeparator}p-(?<paragraphNumber>$INTEGER_REGEX)$pathSeparator(?<testType>pos|neg)$pathSeparator(?<sentenceNumber>$INTEGER_REGEX)\.(?<testNumber>$INTEGER_REGEX)\.kt$""")
val testInfoPattern: Pattern =
Pattern.compile(MULTILINE_COMMENT_REGEX.format("""KOTLIN $testAreaRegex SPEC TEST \($testTypeRegex\)$lineSeparator(?<infoElements>[\s\S]*?$lineSeparator)"""))
val testCaseInfoSinglelinePattern: Pattern = Pattern.compile(SINGLELINE_COMMENT_REGEX.format(testCaseInfoRegex))
val testCaseInfoMultilinePattern: Pattern = Pattern.compile(MULTILINE_COMMENT_REGEX.format(testCaseInfoRegex))
private fun getTestInfo(
testInfoMatcher: Matcher,
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
testCases: List<SpecTestCase>,
unexpectedBehavior: Boolean = false,
issues: Set<String>? = null
): SpecTest {
val sectionMatcher = testInfoElements[SpecTestFileInfoElementType.SECTION]!!.additionalMatcher!!
val sentenceMatcher = testInfoElements[SpecTestFileInfoElementType.SENTENCE]!!.additionalMatcher!!
return SpecTest(
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
TestType.valueOf(testInfoMatcher.group("testType")),
sectionMatcher.group("number"),
sectionMatcher.group("name"),
testInfoElements[SpecTestFileInfoElementType.PARAGRAPH]!!.content.toInt(),
sentenceMatcher.group("number").toInt(),
sentenceMatcher.group("text"),
testInfoElements[SpecTestFileInfoElementType.NUMBER]!!.content.toInt(),
testInfoElements[SpecTestFileInfoElementType.DESCRIPTION]!!.content,
testCases,
unexpectedBehavior,
issues
)
}
private fun getTestInfo(testInfoMatcher: Matcher): SpecTest {
return SpecTest(
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
TestType.fromValue(testInfoMatcher.group("testType"))!!,
testInfoMatcher.group("sectionNumber"),
testInfoMatcher.group("sectionName"),
testInfoMatcher.group("paragraphNumber").toInt(),
testInfoMatcher.group("sentenceNumber").toInt(),
testNumber = testInfoMatcher.group("testNumber").toInt()
)
}
private fun parseIssues(issues: SpecTestInfoElementContent?) = issues?.content?.split(",")
private fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) = SpecTestCase(
1,
description = testInfoElements[SpecTestFileInfoElementType.DESCRIPTION]!!.content,
unexpectedBehavior = testInfoElements.contains(SpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR),
issues = parseIssues(testInfoElements[SpecTestFileInfoElementType.ISSUES])
)
private fun getTestCasesInfo(testCaseInfoMatcher: Matcher, infoElements: SpecTestInfoElements<SpecTestInfoElementType>): List<SpecTestCase> {
val testCases = mutableListOf<SpecTestCase>()
var testCasesCounter = 1
while (testCaseInfoMatcher.find()) {
val caseInfoElements = getTestInfoElements<SpecTestCaseInfoElementType>(testCaseInfoMatcher.group("infoElements"))
testCases.add(
SpecTestCase(
testCasesCounter++,
caseInfoElements[SpecTestCaseInfoElementType.CASE_DESCRIPTION]!!.content,
caseInfoElements.contains(SpecTestCaseInfoElementType.UNEXPECTED_BEHAVIOUR),
parseIssues(caseInfoElements[SpecTestCaseInfoElementType.ISSUES])
)
)
}
if (testCases.isEmpty()) testCases.add(getSingleTestCase(infoElements))
return testCases
}
private inline fun <reified T : Enum<T>> getTestInfoElements(testInfoElements: String): SpecTestInfoElements<SpecTestInfoElementType> {
val testInfoElementsMap = mutableMapOf<SpecTestInfoElementType, SpecTestInfoElementContent>()
val testInfoElementMatcher = testInfoElementPattern.matcher(testInfoElements)
while (testInfoElementMatcher.find()) {
val testInfoOriginalElementName = testInfoElementMatcher.group("name")
val testInfoElementName: SpecTestInfoElementType
try {
testInfoElementName = enumValueOf<T>(testInfoOriginalElementName.replace(" ", "_")) as SpecTestInfoElementType
} catch (e: IllegalArgumentException) {
throw SpecTestValidationException(
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"Unknown '$testInfoOriginalElementName' test info element name."
)
}
val testInfoElementValue = testInfoElementMatcher.group("value")
val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue)
if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find())
throw SpecTestValidationException(
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"'$testInfoElementValue' in '$testInfoElementName' is not parsed."
)
testInfoElementsMap[testInfoElementName] = SpecTestInfoElementContent(testInfoElementValue, testInfoElementValueMatcher)
}
enumValues<T>().forEach {
it as SpecTestInfoElementType
if (it.required && !testInfoElementsMap.contains(it)) {
throw SpecTestValidationException(
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"$it in case or test info is required."
)
}
}
return testInfoElementsMap
}
private fun getIssues(testCases: List<SpecTestCase>, testIssues: List<String>?): Set<String> {
val issues = mutableSetOf<String>()
testCases.forEach {
if (it.issues != null) issues.addAll(it.issues)
}
if (testIssues != null) issues.addAll(testIssues)
return issues
}
}
fun parseTestInfo() {
val testInfoByFilenameMatcher = testPathPattern.matcher(testDataFile.path)
if (!testInfoByFilenameMatcher.find())
throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
val fileContent = testDataFile.readText()
val testInfoByContentMatcher = testInfoPattern.matcher(fileContent)
if (!testInfoByContentMatcher.find())
throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID)
val testInfoElements = getTestInfoElements<SpecTestFileInfoElementType>(testInfoByContentMatcher.group("infoElements"))
val testCases = getTestCasesInfo(testCaseInfoSinglelinePattern.matcher(fileContent), testInfoElements) +
getTestCasesInfo(testCaseInfoMultilinePattern.matcher(fileContent), testInfoElements)
testInfoByFilename = getTestInfo(testInfoByFilenameMatcher)
testInfoByContent = getTestInfo(
testInfoByContentMatcher,
testInfoElements,
testCases = testCases,
unexpectedBehavior = testInfoElements.contains(SpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR) || testCases.any { it.unexpectedBehavior },
issues = getIssues(testCases, parseIssues(testInfoElements[SpecTestFileInfoElementType.ISSUES]))
)
if (!testInfoByFilename.checkConsistency(testInfoByContent))
throw SpecTestValidationException(SpecTestValidationFailedReason.FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY)
}
protected fun validateTestType(computedTestType: TestType) {
if (computedTestType != testInfo.testType) {
val isNotNegative = computedTestType == TestType.POSITIVE && testInfo.testType == TestType.NEGATIVE
val isNotPositive = computedTestType == TestType.NEGATIVE && testInfo.testType == TestType.POSITIVE
val reason = when {
isNotNegative -> SpecTestValidationFailedReason.TEST_IS_NOT_NEGATIVE
isNotPositive -> SpecTestValidationFailedReason.TEST_IS_NOT_POSITIVE
else -> SpecTestValidationFailedReason.UNKNOWN
}
throw SpecTestValidationException(reason)
}
}
fun printTestInfo() {
println("--------------------------------------------------")
if (testInfoByContent.unexpectedBehavior!!)
println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)")
println("$testArea ${testInfoByFilename.testType} SPEC TEST")
println("SECTION: ${testInfoByFilename.sectionNumber} ${testInfoByContent.sectionName} (paragraph: ${testInfoByFilename.paragraphNumber})")
println("SENTENCE ${testInfoByContent.sentenceNumber}: ${testInfoByContent.sentence}")
println("TEST NUMBER: ${testInfoByContent.testNumber}")
println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}")
println("DESCRIPTION: ${testInfoByContent.description}")
if (testInfoByContent.issues!!.isNotEmpty()) {
println("LINKED ISSUES: ${testInfoByContent.issues!!.joinToString(", ")}")
}
}
}
@@ -0,0 +1,291 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
import java.io.File
import java.util.regex.Matcher
import java.util.regex.Pattern
enum class TestType(val type: String) {
POSITIVE("pos"),
NEGATIVE("neg");
companion object {
private val map = TestType.values().associateBy(TestType::type)
fun fromValue(type: String) = map[type]
}
}
enum class TestArea {
PSI,
DIAGNOSTICS,
CODEGEN
}
enum class SpecTestLinkedType {
LINKED,
NOT_LINKED
}
interface SpecTestInfoElementType {
val valuePattern: Pattern?
val required: Boolean
}
enum class SpecTestCaseInfoElementType(
override val valuePattern: Pattern? = null,
override val required: Boolean = false
) : SpecTestInfoElementType {
CASE_DESCRIPTION(required = true),
ISSUES(valuePattern = LinkedSpecTestFileInfoElementType.ISSUES.valuePattern),
UNEXPECTED_BEHAVIOUR,
DISCUSSION,
NOTE
}
data class SpecTestInfoElementContent(
val content: String,
val additionalMatcher: Matcher? = null
)
data class SpecTestCase(
val number: Int,
val description: String,
val unexpectedBehavior: Boolean,
val issues: List<String>?
)
enum class SpecTestValidationFailedReason(val description: String) {
FILENAME_NOT_VALID("Incorrect test filename or folder name."),
TESTINFO_NOT_VALID("Test info is incorrect."),
FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY("Test info from filepath and file content is not consistency"),
TEST_IS_NOT_POSITIVE("Test is not positive because it contains error elements (PsiErrorElement or diagnostic with error severity)."),
TEST_IS_NOT_NEGATIVE("Test is not negative because it not contains error type elements (PsiErrorElement or diagnostic with error severity)."),
UNKNOWN("Unknown validation error.")
}
class SpecTestValidationException(reason: SpecTestValidationFailedReason, details: String = "") : Exception() {
val description = "${reason.description} $details"
}
typealias SpecTestInfoElements<T> = Map<T, SpecTestInfoElementContent>
interface SpecTestValidatorHelperObject {
val pathPartRegex: String
val filenameRegex: String
fun getPathPattern(): Pattern
}
abstract class AbstractSpecTest(
val testArea: TestArea,
val testType: TestType,
val section: String,
val testNumber: Int,
val description: String? = null,
val cases: List<SpecTestCase>? = null,
val unexpectedBehavior: Boolean? = null,
val issues: Set<String>? = null
) {
abstract fun checkConsistency(other: AbstractSpecTest): Boolean
}
abstract class AbstractSpecTestValidator<T : AbstractSpecTest>(private val testDataFile: File) {
val testInfo by lazy { testInfoByContent }
protected lateinit var testInfoByFilename: T
protected lateinit var testInfoByContent: T
abstract val testPathPattern: Pattern
abstract val testInfoPattern: Pattern
companion object {
const val ISSUE_TRACKER = "https://youtrack.jetbrains.com/issue/"
const val INTEGER_REGEX = """[1-9]\d*"""
const val MULTILINE_COMMENT_REGEX = """\/\*\s*%s\s+\*\/\n*"""
private const val SINGLELINE_COMMENT_REGEX = """\/\/\s*%s\n*"""
val pathSeparator: String = Pattern.quote(File.separator)
val lineSeparator: String = System.lineSeparator()
val testAreaRegex = """(?<testArea>${TestArea.values().joinToString("|")})"""
val testTypeRegex = """(?<testType>${TestType.values().joinToString("|")})"""
val dirsByLinkedType = mapOf(
SpecTestLinkedType.LINKED to "linked",
SpecTestLinkedType.NOT_LINKED to "notLinked"
)
private val testInfoElementPattern: Pattern = Pattern.compile("""\s*(?<name>[A-Z ]+?)(?::\s*(?<value>.*?))?$lineSeparator""")
private val testCaseInfoRegex = """(?<infoElements>CASE DESCRIPTION:[\s\S]*?$lineSeparator)$lineSeparator*"""
private val testPathBaseRegexTemplate = """^.*?$pathSeparator(?<testArea>diagnostics|psi|codegen)$pathSeparator%s"""
val testPathRegexTemplate = """$testPathBaseRegexTemplate$pathSeparator(?<testType>pos|neg)/%s$"""
val testCaseInfoSingleLinePattern: Pattern = Pattern.compile(SINGLELINE_COMMENT_REGEX.format(testCaseInfoRegex))
val testCaseInfoMultilinePattern: Pattern = Pattern.compile(MULTILINE_COMMENT_REGEX.format(testCaseInfoRegex))
fun getInstanceByType(testFile: File) = when {
Pattern.compile(testPathBaseRegexTemplate.format(LinkedSpecTestValidator.pathPartRegex)).matcher(testFile.absolutePath).find() ->
LinkedSpecTestValidator(testFile)
Pattern.compile(testPathBaseRegexTemplate.format(NotLinkedSpecTestValidator.pathPartRegex)).matcher(testFile.absolutePath).find() ->
NotLinkedSpecTestValidator(testFile)
else -> throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
}
fun getInstanceByType(testPath: String) = getInstanceByType(File(testPath))
private fun getTestInfoElements(
testInfoElementRules: Array<out SpecTestInfoElementType>,
testInfoElements: String
): SpecTestInfoElements<SpecTestInfoElementType> {
val testInfoElementsMap = mutableMapOf<SpecTestInfoElementType, SpecTestInfoElementContent>()
val testInfoElementMatcher = testInfoElementPattern.matcher(testInfoElements)
while (testInfoElementMatcher.find()) {
val testInfoOriginalElementName = testInfoElementMatcher.group("name")
val testInfoElementName = testInfoElementRules.find {
it as Enum<*>
it.name == testInfoOriginalElementName.replace(" ", "_")
} ?: throw SpecTestValidationException(
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"Unknown '$testInfoOriginalElementName' test info element name."
)
val testInfoElementValue = testInfoElementMatcher.group("value")
val testInfoElementValueMatcher = testInfoElementName.valuePattern?.matcher(testInfoElementValue)
if (testInfoElementValueMatcher != null && !testInfoElementValueMatcher.find())
throw SpecTestValidationException(
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"'$testInfoElementValue' in '$testInfoElementName' is not parsed."
)
testInfoElementsMap[testInfoElementName] =
SpecTestInfoElementContent(testInfoElementValue ?: "", testInfoElementValueMatcher)
}
testInfoElementRules.forEach {
if (it.required && !testInfoElementsMap.contains(it)) {
throw SpecTestValidationException(
SpecTestValidationFailedReason.TESTINFO_NOT_VALID,
"$it in case or test info is required."
)
}
}
return testInfoElementsMap
}
private fun getIssues(testCases: List<SpecTestCase>, testIssues: List<String>?): Set<String> {
val issues = mutableSetOf<String>()
testCases.forEach {
if (it.issues != null) issues.addAll(it.issues)
}
if (testIssues != null) issues.addAll(testIssues)
return issues
}
fun parseIssues(issues: SpecTestInfoElementContent?) = issues?.content?.split(",")
}
private fun getTestCasesInfo(
testCaseInfoMatcher: Matcher,
infoElements: SpecTestInfoElements<SpecTestInfoElementType>
): List<SpecTestCase> {
val testCases = mutableListOf<SpecTestCase>()
var testCasesCounter = 1
while (testCaseInfoMatcher.find()) {
val caseInfoElements = getTestInfoElements(
SpecTestCaseInfoElementType.values(),
testCaseInfoMatcher.group("infoElements")
)
testCases.add(
SpecTestCase(
testCasesCounter++,
caseInfoElements[SpecTestCaseInfoElementType.CASE_DESCRIPTION]!!.content,
caseInfoElements.contains(SpecTestCaseInfoElementType.UNEXPECTED_BEHAVIOUR),
parseIssues(caseInfoElements[SpecTestCaseInfoElementType.ISSUES])
)
)
}
if (testCases.isEmpty())
testCases.add(getSingleTestCase(infoElements))
return testCases
}
abstract fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) : SpecTestCase
fun testInfoFilter(fileContent: String): String =
testInfoPattern.matcher(fileContent).replaceAll("").let {
testCaseInfoSingleLinePattern.matcher(it).replaceAll("").let {
testCaseInfoMultilinePattern.matcher(it).replaceAll("")
}
}
abstract fun getTestInfo(
testInfoMatcher: Matcher,
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
testCases: List<SpecTestCase>,
unexpectedBehavior: Boolean = false,
issues: Set<String>? = null
): T
abstract fun getTestInfo(testInfoMatcher: Matcher): T
abstract fun parseTestInfo()
abstract fun printTestInfo()
fun parseTestInfo(testInfoElementsRules: Array<out SpecTestInfoElementType>) {
val testInfoByFilenameMatcher = testPathPattern.matcher(testDataFile.canonicalPath)
if (!testInfoByFilenameMatcher.find())
throw SpecTestValidationException(SpecTestValidationFailedReason.FILENAME_NOT_VALID)
val fileContent = testDataFile.readText()
val testInfoByContentMatcher = testInfoPattern.matcher(fileContent)
if (!testInfoByContentMatcher.find())
throw SpecTestValidationException(SpecTestValidationFailedReason.TESTINFO_NOT_VALID)
val testInfoElements = getTestInfoElements(
testInfoElementsRules,
testInfoByContentMatcher.group("infoElements")
)
val testCases = getTestCasesInfo(testCaseInfoSingleLinePattern.matcher(fileContent), testInfoElements) +
getTestCasesInfo(testCaseInfoMultilinePattern.matcher(fileContent), testInfoElements)
testInfoByFilename = getTestInfo(testInfoByFilenameMatcher)
testInfoByContent = getTestInfo(
testInfoByContentMatcher,
testInfoElements,
testCases = testCases,
unexpectedBehavior = testInfoElements.contains(LinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR) || testCases.any { it.unexpectedBehavior },
issues = getIssues(
testCases,
parseIssues(
testInfoElements[LinkedSpecTestFileInfoElementType.ISSUES]
)
)
)
if (!testInfoByFilename.checkConsistency(testInfoByContent))
throw SpecTestValidationException(SpecTestValidationFailedReason.FILEPATH_AND_TESTINFO_IN_FILE_NOT_CONSISTENCY)
}
fun validateTestType(computedTestType: TestType) {
if (computedTestType != testInfo.testType) {
val isNotNegative = computedTestType == TestType.POSITIVE && testInfo.testType == TestType.NEGATIVE
val isNotPositive = computedTestType == TestType.NEGATIVE && testInfo.testType == TestType.POSITIVE
val reason = when {
isNotNegative -> SpecTestValidationFailedReason.TEST_IS_NOT_NEGATIVE
isNotPositive -> SpecTestValidationFailedReason.TEST_IS_NOT_POSITIVE
else -> SpecTestValidationFailedReason.UNKNOWN
}
throw SpecTestValidationException(reason)
}
}
}
@@ -0,0 +1,46 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.Severity
class DiagnosticTestTypeValidator(testFiles: List<BaseDiagnosticsTest.TestFile>) {
private val diagnostics = mutableListOf<Diagnostic>()
private val diagnosticStats = mutableMapOf<String, Int>()
private val diagnosticSeverityStats = mutableMapOf<Severity, Int>()
init {
collectDiagnostics(testFiles)
}
private fun collectDiagnosticStatistic() {
diagnostics.forEach {
val severity = it.factory.severity
diagnosticSeverityStats.run { put(severity, getOrDefault(severity, 0) + 1) }
}
}
private fun collectDiagnostics(files: List<BaseDiagnosticsTest.TestFile>) {
files.forEach {
it.actualDiagnostics.forEach {
val diagnosticName = it.diagnostic.factory.name
diagnosticStats.run { put(diagnosticName, getOrDefault(diagnosticName, 0) + 1) }
diagnostics.add(it.diagnostic)
}
}
collectDiagnosticStatistic()
}
fun computeTestType() =
if (Severity.ERROR in diagnosticSeverityStats) TestType.NEGATIVE else TestType.POSITIVE
fun printDiagnosticStatistic() {
val diagnostics = if (diagnosticStats.isNotEmpty()) "$diagnosticSeverityStats | $diagnosticStats" else "does not contain"
println("DIAGNOSTICS: $diagnostics")
}
}
@@ -0,0 +1,122 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
import java.io.File
import java.util.regex.Matcher
import java.util.regex.Pattern
enum class LinkedSpecTestFileInfoElementType(
override val valuePattern: Pattern? = null,
override val required: Boolean = false
) : SpecTestInfoElementType {
SECTION(required = true),
PARAGRAPH(required = true),
SENTENCE(
valuePattern = Pattern.compile("""\[(?<number>${AbstractSpecTestValidator.INTEGER_REGEX})\](?<text>.*?)"""),
required = true
),
NUMBER(required = true),
DESCRIPTION(required = true),
ISSUES(valuePattern = Pattern.compile("""(KT-[1-9]\d*)(,\s*KT-[1-9]\d*)*""")),
UNEXPECTED_BEHAVIOUR,
DISCUSSION,
NOTE
}
class LinkedSpecTest(
testArea: TestArea,
testType: TestType,
section: String,
val paragraphNumber: Int,
val sentenceNumber: Int,
val sentence: String? = null,
testNumber: Int,
description: String? = null,
cases: List<SpecTestCase>? = null,
unexpectedBehavior: Boolean? = null,
issues: Set<String>? = null
) : AbstractSpecTest(testArea, testType, section, testNumber, description, cases, unexpectedBehavior, issues) {
override fun checkConsistency(other: AbstractSpecTest) =
other is LinkedSpecTest
&& this.section == other.section
&& this.testArea == other.testArea
&& this.testType == other.testType
&& this.testNumber == other.testNumber
&& this.paragraphNumber == other.paragraphNumber
&& this.sentenceNumber == other.sentenceNumber
}
class LinkedSpecTestValidator(testDataFile: File) : AbstractSpecTestValidator<LinkedSpecTest>(testDataFile) {
override val testPathPattern = getPathPattern()
override val testInfoPattern: Pattern =
Pattern.compile(MULTILINE_COMMENT_REGEX.format("""KOTLIN $testAreaRegex SPEC TEST \($testTypeRegex\)$lineSeparator(?<infoElements>[\s\S]*?$lineSeparator)"""))
companion object : SpecTestValidatorHelperObject {
override val pathPartRegex =
"""${dirsByLinkedType[SpecTestLinkedType.LINKED]}$pathSeparator(?<section>[\w-]+)${pathSeparator}p-(?<paragraphNumber>$INTEGER_REGEX)"""
override val filenameRegex = """(?<sentenceNumber>$INTEGER_REGEX)\.(?<testNumber>$INTEGER_REGEX)\.kt"""
override fun getPathPattern(): Pattern = Pattern.compile(testPathRegexTemplate.format(pathPartRegex, filenameRegex))
}
override fun getTestInfo(
testInfoMatcher: Matcher,
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
testCases: List<SpecTestCase>,
unexpectedBehavior: Boolean,
issues: Set<String>?
): LinkedSpecTest {
val sentenceMatcher = testInfoElements[LinkedSpecTestFileInfoElementType.SENTENCE]!!.additionalMatcher!!
return LinkedSpecTest(
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
TestType.valueOf(testInfoMatcher.group("testType")),
testInfoElements[LinkedSpecTestFileInfoElementType.SECTION]!!.content,
testInfoElements[LinkedSpecTestFileInfoElementType.PARAGRAPH]!!.content.toInt(),
sentenceMatcher.group("number").toInt(),
sentenceMatcher.group("text"),
testInfoElements[LinkedSpecTestFileInfoElementType.NUMBER]!!.content.toInt(),
testInfoElements[LinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
testCases,
unexpectedBehavior,
issues
)
}
override fun getTestInfo(testInfoMatcher: Matcher) =
LinkedSpecTest(
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
TestType.fromValue(testInfoMatcher.group("testType"))!!,
testInfoMatcher.group("section"),
testInfoMatcher.group("paragraphNumber").toInt(),
testInfoMatcher.group("sentenceNumber").toInt(),
testNumber = testInfoMatcher.group("testNumber").toInt()
)
override fun parseTestInfo() = parseTestInfo(LinkedSpecTestFileInfoElementType.values())
override fun printTestInfo() {
println("--------------------------------------------------")
if (testInfoByContent.unexpectedBehavior!!)
println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)")
println("${testInfoByFilename.testArea} ${testInfoByFilename.testType} SPEC TEST")
println("SECTION: ${testInfoByContent.section} (paragraph: ${testInfoByFilename.paragraphNumber})")
println("SENTENCE ${testInfoByContent.sentenceNumber}: ${testInfoByContent.sentence}")
println("TEST NUMBER: ${testInfoByContent.testNumber}")
println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}")
println("DESCRIPTION: ${testInfoByContent.description}")
if (testInfoByContent.issues!!.isNotEmpty())
println("LINKED ISSUES: ${testInfoByContent.issues!!.map { ISSUE_TRACKER + it }.joinToString(", ")}")
}
override fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) =
SpecTestCase(
1,
description = testInfoElements[LinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
unexpectedBehavior = testInfoElements.contains(LinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR),
issues = parseIssues(testInfoElements[LinkedSpecTestFileInfoElementType.ISSUES])
)
}
@@ -0,0 +1,112 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. 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.spec.validators
import java.io.File
import java.util.regex.Matcher
import java.util.regex.Pattern
enum class NotLinkedSpecTestFileInfoElementType(
override val valuePattern: Pattern? = null,
override val required: Boolean = false
) : SpecTestInfoElementType {
SECTION(required = true),
CATEGORY(
valuePattern = Pattern.compile("""\w+(,\s+\w+)*"""),
required = true
),
NUMBER(required = true),
DESCRIPTION(required = true),
ISSUES(valuePattern = LinkedSpecTestFileInfoElementType.ISSUES.valuePattern),
UNEXPECTED_BEHAVIOUR,
DISCUSSION,
NOTE
}
class NotLinkedSpecTest(
testArea: TestArea,
testType: TestType,
section: String,
val categories: List<String>,
testNumber: Int,
description: String? = null,
cases: List<SpecTestCase>? = null,
unexpectedBehavior: Boolean? = null,
issues: Set<String>? = null
) : AbstractSpecTest(testArea, testType, section, testNumber, description, cases, unexpectedBehavior, issues) {
override fun checkConsistency(other: AbstractSpecTest) =
other is NotLinkedSpecTest
&& this.section == other.section
&& this.testArea == other.testArea
&& this.testType == other.testType
&& this.categories.joinToString(",") == other.categories.joinToString(",")
&& this.testNumber == other.testNumber
}
class NotLinkedSpecTestValidator(testDataFile: File) : AbstractSpecTestValidator<NotLinkedSpecTest>(testDataFile) {
override val testPathPattern = getPathPattern()
override val testInfoPattern: Pattern =
Pattern.compile(MULTILINE_COMMENT_REGEX.format("""KOTLIN $testAreaRegex NOT LINKED SPEC TEST \($testTypeRegex\)$lineSeparator(?<infoElements>[\s\S]*?$lineSeparator)"""))
companion object : SpecTestValidatorHelperObject {
override val pathPartRegex =
"""${dirsByLinkedType[SpecTestLinkedType.NOT_LINKED]}$pathSeparator(?<section>[\w-]+)$pathSeparator(?<categories>(?:[\w-]+)(?:/[\w-]+)*?)"""
override val filenameRegex = """(?<testNumber>$INTEGER_REGEX)\.kt"""
override fun getPathPattern(): Pattern = Pattern.compile(testPathRegexTemplate.format(pathPartRegex, filenameRegex))
}
override fun getTestInfo(
testInfoMatcher: Matcher,
testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>,
testCases: List<SpecTestCase>,
unexpectedBehavior: Boolean,
issues: Set<String>?
) =
NotLinkedSpecTest(
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
TestType.valueOf(testInfoMatcher.group("testType")),
testInfoElements[NotLinkedSpecTestFileInfoElementType.SECTION]!!.content,
testInfoElements[NotLinkedSpecTestFileInfoElementType.CATEGORY]!!.content.split(Regex(""",\s*""")),
testInfoElements[NotLinkedSpecTestFileInfoElementType.NUMBER]!!.content.toInt(),
testInfoElements[NotLinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
testCases,
unexpectedBehavior,
issues
)
override fun getTestInfo(testInfoMatcher: Matcher) =
NotLinkedSpecTest(
TestArea.valueOf(testInfoMatcher.group("testArea").toUpperCase()),
TestType.fromValue(testInfoMatcher.group("testType"))!!,
testInfoMatcher.group("section"),
testInfoMatcher.group("categories").split("/"),
testNumber = testInfoMatcher.group("testNumber").toInt()
)
override fun parseTestInfo() = parseTestInfo(NotLinkedSpecTestFileInfoElementType.values())
override fun printTestInfo() {
println("--------------------------------------------------")
if (testInfoByContent.unexpectedBehavior!!)
println("(!!!) HAS UNEXPECTED BEHAVIOUR (!!!)")
println("${testInfoByFilename.testArea} ${testInfoByFilename.testType} NOT LINKED SPEC TEST")
println("SECTION: ${testInfoByContent.section}")
println("CATEGORIES: ${testInfoByContent.categories.joinToString(", ")}")
println("TEST NUMBER: ${testInfoByContent.testNumber}")
println("NUMBER OF TEST CASES: ${testInfoByContent.cases!!.size}")
println("DESCRIPTION: ${testInfoByContent.description}")
if (testInfoByContent.issues!!.isNotEmpty())
println("LINKED ISSUES: ${testInfoByContent.issues!!.map { ISSUE_TRACKER + it }.joinToString(", ")}")
}
override fun getSingleTestCase(testInfoElements: SpecTestInfoElements<SpecTestInfoElementType>) =
SpecTestCase(
1,
description = testInfoElements[NotLinkedSpecTestFileInfoElementType.DESCRIPTION]!!.content,
unexpectedBehavior = testInfoElements.contains(NotLinkedSpecTestFileInfoElementType.UNEXPECTED_BEHAVIOUR),
issues = parseIssues(testInfoElements[NotLinkedSpecTestFileInfoElementType.ISSUES])
)
}