[Spec tests] Review fix tests for try-expression and if-expression
This commit is contained in:
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// SKIP_TXT
|
||||
// FULL_JDK
|
||||
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, conditional-expression -> paragraph 6 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: The type of the condition expression must be a subtype of kotlin.Boolean
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
// MODULE: libModule
|
||||
// FILE: libModule/JavaContainer.java
|
||||
package libModule;
|
||||
|
||||
public class JavaContainer {
|
||||
public static boolean ab;
|
||||
public static final Boolean aB;
|
||||
public static Object aO = false;
|
||||
}
|
||||
|
||||
// MODULE: mainModule(libModule)
|
||||
// FILE: KotlinClass.kt
|
||||
package mainModule
|
||||
import libModule.*
|
||||
import checkSubtype
|
||||
|
||||
/*
|
||||
* TESTCASE NUMBER: 1
|
||||
* UNEXPECTED BEHAVIOUR
|
||||
* ISSUES: KT-35517
|
||||
*/
|
||||
fun case1() {
|
||||
val a: Any = true
|
||||
if (<!TYPE_MISMATCH, TYPE_MISMATCH!>a<!>) { "true" } else "false"
|
||||
checkSubtype<Boolean>(<!TYPE_MISMATCH!>a<!>)
|
||||
}
|
||||
|
||||
/*
|
||||
* TESTCASE NUMBER: 2
|
||||
* UNEXPECTED BEHAVIOUR
|
||||
* ISSUES: KT-35517
|
||||
*/
|
||||
fun case2() {
|
||||
val a = JavaContainer.aO
|
||||
if (<!TYPE_MISMATCH, TYPE_MISMATCH!>a<!>) { "true" } else "false"
|
||||
checkSubtype<Boolean>(<!TYPE_MISMATCH!>a<!>)
|
||||
}
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNREACHABLE_CODE -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
// SKIP_TXT
|
||||
// FULL_JDK
|
||||
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-218
|
||||
* PLACE: expressions, conditional-expression -> paragraph 6 -> sentence 1
|
||||
* NUMBER: 1
|
||||
* DESCRIPTION: The type of the condition expression must be a subtype of kotlin.Boolean
|
||||
* HELPERS: checkType
|
||||
*/
|
||||
|
||||
// MODULE: libModule
|
||||
// FILE: libModule/JavaContainer.java
|
||||
package libModule;
|
||||
|
||||
public class JavaContainer {
|
||||
public static boolean ab;
|
||||
public static Boolean aB;
|
||||
public static final Object aO = false;
|
||||
}
|
||||
|
||||
// MODULE: mainModule(libModule)
|
||||
// FILE: KotlinClass.kt
|
||||
package mainModule
|
||||
import libModule.*
|
||||
import checkSubtype
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1() {
|
||||
val a = JavaContainer.ab
|
||||
if (a) { "true" } else "false"
|
||||
checkSubtype<Boolean>(a)
|
||||
checkSubtype<Boolean>(false)
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
fun case2() {
|
||||
val a = JavaContainer.aB
|
||||
if (a) { "true" } else "false"
|
||||
checkSubtype<Boolean>(a)
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case3() {
|
||||
val a = JavaContainer.aO as Boolean
|
||||
if (a) { "true" } else "false"
|
||||
checkSubtype<Boolean>(a)
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
fun case4(a: Nothing) {
|
||||
checkSubtype<Boolean>(a)
|
||||
if (a) { "true" } else "false"
|
||||
|
||||
}
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"6": {
|
||||
"neg": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 2,
|
||||
"description": "The type of the condition expression must be a subtype of kotlin.Boolean",
|
||||
"unexpectedBehaviour": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 4,
|
||||
"description": "The type of the condition expression must be a subtype of kotlin.Boolean",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt9929",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt9929.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt10811",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt10811.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt9972",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt9972.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt10809",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt10809.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt10439",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt10439.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"5": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt9929",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt9929.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt9972",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt9972.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-152",
|
||||
"casesNumber": 0,
|
||||
"description": "Kt10439",
|
||||
"path": "compiler/testData/diagnostics/tests/when/kt10439.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
-19
@@ -145,9 +145,9 @@
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 2,
|
||||
"casesNumber": 3,
|
||||
"description": "The type of the try-expression is the least upper bound of the types of the last expressions of the try body and the last expressions of all the catch blocks",
|
||||
"unexpectedBehaviour": false
|
||||
"unexpectedBehaviour": true
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -162,15 +162,15 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"9": {
|
||||
"neg": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 2,
|
||||
"casesNumber": 3,
|
||||
"description": "The type of the try-expression is the least upper bound of the types of the last expressions of the try body and the last expressions of all the catch blocks",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
"unexpectedBehaviour": true
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -182,20 +182,6 @@
|
||||
"description": "The type of the try-expression is the least upper bound of the types of the last expressions of the try body and the last expressions of all the catch blocks",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 1,
|
||||
"description": "If an exception was thrown, but no catch block matched its type, the finally block is evaluated before propagating the exception up the call stack.",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos/2.1.kt",
|
||||
"unexpectedBehaviour": true
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 1,
|
||||
"description": "If no exception is thrown during the evaluation of the try body, no catch blocks are executed, the finally block is evaluated after the try body, and the program execution continues as normal.",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -240,5 +226,25 @@
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"4": {
|
||||
"pos": {
|
||||
"1": [
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 1,
|
||||
"description": "If an exception was thrown, but no catch block matched its type, the finally block is evaluated before propagating the exception up the call stack.",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos/2.1.kt",
|
||||
"unexpectedBehaviour": true
|
||||
},
|
||||
{
|
||||
"specVersion": "0.1-218",
|
||||
"casesNumber": 1,
|
||||
"description": "If no exception is thrown during the evaluation of the try body, no catch blocks are executed, the finally block is evaluated after the try body, and the program execution continues as normal.",
|
||||
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos/1.1.kt",
|
||||
"unexpectedBehaviour": false
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user