[Spec tests] Add tests for try-expression (paragraphs 1, 2, 5-9)

This commit is contained in:
anastasiia.spaseeva
2019-12-13 15:59:33 +03:00
parent 3aa3f0c50c
commit e865327386
32 changed files with 1876 additions and 0 deletions
@@ -0,0 +1,2 @@
java.lang.Exception
_2_1Kt.throwException(2.1.kt:14)
@@ -0,0 +1,28 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 2 -> sentence 1
* NUMBER: 1
* DESCRIPTION: catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.
* EXCEPTION: runtime
*/
fun throwException(b: Boolean) = run { if (b) throw Exception() }
class ExcA() : Exception()
fun box() {
var flag = false
try {
throwException(true)
flag = true
} catch (e: ExcA) {
}
//result java.lang.Exception cos of type mismatch
}
@@ -0,0 +1,26 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 2 -> sentence 1
* NUMBER: 1
* DESCRIPTION: catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.
*/
fun throwException(b: Boolean) = run { if (b) throw Exception() }
fun box(): String {
var flag = false
try {
throwException(true)
flag = true
} catch (e: Exception) {
if (!flag)
return "OK"
}
return "NOK"
}
@@ -0,0 +1,33 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 2 -> sentence 1
* NUMBER: 2
* DESCRIPTION: catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.
*/
fun throwExceptionB(b: Boolean) = run { if (b) throw ExcB() }
class ExcA() : Exception()
class ExcB() : Exception()
fun box(): String {
var flag = false
try {
throwExceptionB(true)
flag = true
} catch (e: ExcA) {
return "NOK"
} catch (e: ExcB) {
return if (flag)
"NOK"
else "OK"
}
return "NOK"
}
@@ -0,0 +1,33 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 2 -> sentence 1
* NUMBER: 3
* DESCRIPTION: catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.
*/
fun throwExceptionB(b: Boolean) = run { if (b) throw ExcB() }
class ExcA() : Exception()
class ExcB() : Exception()
fun box(): String {
var flag = false
try {
throwExceptionB(true)
flag = true
} catch (e: ExcA) {
return "NOK"
} catch (e: Exception) {
return if (flag)
"NOK"
else "OK"
}
return "NOK"
}
@@ -0,0 +1,33 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 3
* NUMBER: 1
* DESCRIPTION: If there are several catch blocks which match the exception type, the first one is picked.
*/
fun throwExceptionB(b: Boolean) = run { if (b) throw ExcB() }
class ExcA() : Exception()
class ExcB() : Exception()
fun box(): String {
var flag = false
try {
throwExceptionB(true)
flag = true
} catch (e: ExcA) {
return "NOK"
} catch (e: Exception) {
return if (flag)
"NOK"
else "OK"
}catch (e : ExcB){
return "NOK"
}
return "NOK"
}
@@ -0,0 +1,34 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 3
* NUMBER: 2
* DESCRIPTION: If there are several catch blocks which match the exception type, the first one is picked.
*/
fun throwExceptionB(b: Boolean) = run { if (b) throw ExcB() }
class ExcA() : Exception()
class ExcB() : Exception()
fun box(): String {
var flag = false
try {
throwExceptionB(true)
flag = true
} catch (e: ExcA) {
return "NOK"
} catch (e: ExcB) {
return if (flag)
"NOK"
else "OK"
}catch (e : Exception){
return "NOK"
}
return "NOK"
}
@@ -0,0 +1,2 @@
ExcA
_3_1Kt.throwExceptionA(3.1.kt:15)
@@ -0,0 +1,28 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 5 -> sentence 3
* RELEVANT PLACES: expressions, try-expression -> paragraph 4 -> sentence 1
* exceptions, catching-exceptions -> paragraph 4 -> sentence 1
* NUMBER: 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
* EXCEPTION: runtime
*/
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
class ExcA() : Exception()
class ExcB() : Exception()
fun box() {
try {
throwExceptionA(true)
} catch (e: ExcB) {
} finally {
}
}
@@ -0,0 +1,29 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 5 -> sentence 1
* RELEVANT PLACES: expressions, try-expression -> paragraph 4 -> sentence 1
* NUMBER: 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.
*/
fun box(): String {
var isTryExecuted = false
var isCatched = false
var isFinallyExecuted = false
var isExecutedFully = false
try {
isTryExecuted = true
} catch (e: Exception) {
isCatched = true
} finally {
isFinallyExecuted = true
}
isExecutedFully = true
return if (isTryExecuted && !isCatched && isFinallyExecuted && isExecutedFully) "OK"
else "NOK"
}
@@ -0,0 +1,31 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 5 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 4 -> sentence 1
* NUMBER: 1
* DESCRIPTION: the finally block is evaluated after the evaluation of the matching catch block.
*/
fun throwException(b: Boolean) = run { if (b) throw Exception() }
fun box(): String {
var isTryExecuted = false
var isCatched = false
var isFinallyExecuted = false
var isExecutedFully = false
try {
isTryExecuted = true
throwException(true)
} catch (e: Exception) {
isCatched = true
} finally {
isFinallyExecuted = true
}
isExecutedFully = true
return if (isTryExecuted &&isCatched && isFinallyExecuted && isExecutedFully) "OK"
else "NOK"
}
@@ -0,0 +1,46 @@
// SKIP_TXT
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 5 -> sentence 3
* RELEVANT PLACES: expressions, try-expression -> paragraph 4 -> sentence 1
* exceptions, catching-exceptions -> paragraph 4 -> sentence 1
* NUMBER: 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
*/
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
class ExcA() : Exception()
class ExcB() : Exception()
fun box(): String {
var isTryExecuted = false
var isCatched = false
var isFinallyExecuted = false
var isExecutedFully = false
var isTryExpressionPropagated = false
try {
try {
isTryExecuted = true
throwExceptionA(true)
} catch (e: ExcB) {
isCatched = true
} finally {
isFinallyExecuted = true
}
} catch (e: ExcA) {
isTryExpressionPropagated = true
}
isExecutedFully = true
return if (isTryExecuted &&
!isCatched &&
isFinallyExecuted &&
isTryExpressionPropagated &&
isExecutedFully
) "OK"
else "NOK"
}
@@ -0,0 +1,19 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 6 -> sentence 1
* NUMBER: 1
* DESCRIPTION:The value of the try-expression is the same as the value of the last expression of the try or catch block
*/
fun box(): String {
var a = 1
val tryVal1 = try { 3 } catch (e: Exception) { 5 }
val tryVal2 = try { 3 ; throw Exception() } catch (e: Exception) { 5 }
if (tryVal1 == 3 && tryVal2 == 5)
return "OK"
else return "NOK"
}
@@ -0,0 +1,19 @@
// WITH_RUNTIME
/*
* KOTLIN CODEGEN BOX SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 7 -> sentence 1
* NUMBER: 1
* DESCRIPTION: finally block has no effect on the value returned by the try-expression
*/
fun box(): String {
var a = 1
val tryVal1 = try { 3 } catch (e: Exception) { 5 } finally { 100}
val tryVal2 = try { 3; throw Exception() } catch (e: Exception) { 5 } finally { 100 }
if (tryVal1 == 3 && tryVal2 == 5)
return "OK"
else return "NOK"
}
@@ -0,0 +1,182 @@
{
"7": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "finally block has no effect on the value returned by the try-expression",
"unexpectedBehaviour": false
}
]
}
},
"6": {
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "The value of the try-expression is the same as the value of the last expression of the try or catch block",
"unexpectedBehaviour": false
}
]
}
},
"2": {
"neg": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/neg/2.1.kt",
"unexpectedBehaviour": false
}
]
},
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/2.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/2.3.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/2.2.kt",
"unexpectedBehaviour": false
}
],
"3": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "If there are several catch blocks which match the exception type, the first one is picked.",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "If there are several catch blocks which match the exception type, the first one is picked.",
"unexpectedBehaviour": false
}
]
}
},
"5": {
"neg": {
"3": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"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",
"unexpectedBehaviour": false
}
]
},
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "the finally block is evaluated after the evaluation of the matching catch block.",
"unexpectedBehaviour": false
}
],
"3": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"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",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"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.",
"unexpectedBehaviour": false
}
]
}
},
"4": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"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/codegen/box/linked/expressions/try-expression/p-5/neg/3.1.kt",
"unexpectedBehaviour": false
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 0,
"description": "the finally block is evaluated after the evaluation of the matching catch block.",
"path": "compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/pos/2.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"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/codegen/box/linked/expressions/try-expression/p-5/pos/3.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 0,
"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/codegen/box/linked/expressions/try-expression/p-5/pos/1.1.kt",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -0,0 +1,35 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE:expressions, try-expression -> paragraph 1 -> sentence 1
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: try-expression has to start with a try body
*/
fun throwException(): Nothing = throw Exception()
// TESTCASE NUMBER: 1
fun case1() {
try <!SYNTAX!><!>throwException()
}<!SYNTAX!><!>
// TESTCASE NUMBER: 2
fun case2() {
try <!SYNTAX!><!SYNTAX!><!>=<!> throwException()
}<!SYNTAX!><!>
// TESTCASE NUMBER: 3
fun case3() {
try
<!SYNTAX!><!>val a = ""
}<!SYNTAX!><!>
@@ -0,0 +1,75 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 3
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: try-expression has to start with a try body and continue with zero ore more catch blocks
*/
fun throwException(): Nothing = throw Exception()
class ExcA() : Exception()
class ExcB() : Exception()
// TESTCASE NUMBER: 1
fun case1() {
try <!SYNTAX!><!>val a = ""
<!UNRESOLVED_REFERENCE!>catch<!>(<!UNRESOLVED_REFERENCE!>e<!><!SYNTAX!>: Exception<!>) {}
}<!SYNTAX!><!>
// TESTCASE NUMBER: 2
fun case2() {
try {
val a = ""
} catch (e: Exception)<!SYNTAX!><!>
}
// TESTCASE NUMBER: 3
fun case3() {
try {
val a = ""
throwException()
} catch (e: java.lang.IllegalArgumentException) {
} catch (e: ExcB)<!SYNTAX!><!>
}
// TESTCASE NUMBER: 4
fun case4() {
try {
throwException()
} catch (<!SYNTAX!><!>) {
}
}
// TESTCASE NUMBER: 5
fun case5() {
try {
throwException()
} catch (e: ExcA, <!SYNTAX!>e2<!><!SYNTAX!><!> <!SYNTAX!>: ExcB)<!>
<!UNUSED_LAMBDA_EXPRESSION!>{}<!>
}
// TESTCASE NUMBER: 6
fun case6() {
try {
val a = ""
throwException()
} catch (e: java.lang.IllegalArgumentException) {
} catch (e: ExcA)<!SYNTAX!><!>
catch (e: ExcB) {
}
}
@@ -0,0 +1,79 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 4
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: try-expression has to start with a try body, catch blocks and finally block
*/
fun throwException(): Nothing = throw Exception()
class ExcA() : Exception()
class ExcB() : Exception()
// TESTCASE NUMBER: 1
fun case1() {
try {
throwException()
} catch (e: ExcA) {
} finally {
} <!UNRESOLVED_REFERENCE!>catch<!> (<!UNRESOLVED_REFERENCE!>e<!><!SYNTAX!><!SYNTAX!><!>: ExcB)<!> <!UNUSED_LAMBDA_EXPRESSION!>{
}<!>
}
// TESTCASE NUMBER: 2
fun case2() {
try {
throwException()
} catch (e: ExcB) {
} finally
<!SYNTAX!><!>}<!SYNTAX!><!>
// TESTCASE NUMBER: 3
fun case3() {
try {
throwException()
} finally
<!SYNTAX!><!>}<!SYNTAX!><!>
@@ -0,0 +1,31 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 5
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: A valid try-expression must have at least one catch or finally block.
*/
fun throwException(): Nothing = throw Exception()
// TESTCASE NUMBER: 1
fun case1() {
try {
throwException()
}<!SYNTAX!><!>
}
// TESTCASE NUMBER: 2
fun case2() {
try {
val a = "foo"
}<!SYNTAX!><!>
}
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE:expressions, try-expression -> paragraph 1 -> sentence 1
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* expressions, try-expression -> paragraph 1 -> sentence 5
* NUMBER: 1
* DESCRIPTION: try-expression has to start with a try body
*/
fun throwException(): Nothing = throw Exception()
// TESTCASE NUMBER: 1
fun case1() {
try {
throwException()
}finally {
"a"
}
}
// TESTCASE NUMBER: 2
fun case2() {
try {
<!UNREACHABLE_CODE!>val a =<!> throwException()
}catch (e: Exception) {
"a"
}
}
@@ -0,0 +1,38 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 3
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: try-expression has to start with a try body and continue with zero ore more catch blocks
*/
fun throwException(): Nothing = throw Exception()
// TESTCASE NUMBER: 1
fun case1() {
try {
val a = ""
} catch (e: Exception) {
}
}
// TESTCASE NUMBER: 2
fun case2() {
try {
val a = ""
throwException()
} catch (e: IllegalArgumentException) {
} catch (e: ExcA) {
} catch (e: ExcB) {
}
}
class ExcA() : Exception()
class ExcB() : Exception()
@@ -0,0 +1,61 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 3
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 2
* DESCRIPTION: catch is a soft keyword
*/
fun throwException(): Nothing = throw Exception()
// TESTCASE NUMBER: 1
class Case1 {
fun catch(e: Exception) {}
fun case1() {
catch(Exception())
}
}
// TESTCASE NUMBER: 2
class Case2 {
class catch(e: Exception) {}
fun case2() {
val c = catch(Exception())
}
}
// TESTCASE NUMBER: 3
class Case3 {
fun catch() {}
fun case3() {
catch()
}
}
// TESTCASE NUMBER: 4
class Case4 {
class catch() {}
fun case4() {
val c = catch()
}
}
// TESTCASE NUMBER: 5
class Case5() {
interface catch
fun case5(){
val c = object :catch{}
}
}
@@ -0,0 +1,36 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 4
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 1
* DESCRIPTION: try-expression has to start with a try body, catch blocks and finally block
*/
fun throwException(): Nothing = throw Exception()
class ExcA() : Exception()
class ExcB() : Exception()
// TESTCASE NUMBER: 1
fun case1() {
try {
throwException()
} catch (e: ExcA) {
} catch (e: ExcB) {
} finally {
}
}
// TESTCASE NUMBER: 2
fun case2() {
try {
throwException()
} finally {
}
}
@@ -0,0 +1,61 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_VARIABLE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 1 -> sentence 4
* RELEVANT PLACES: expressions, try-expression -> paragraph 1 -> sentence 2
* NUMBER: 2
* DESCRIPTION: finally is a soft keyword
*/
fun throwException(): Nothing = throw Exception()
// TESTCASE NUMBER: 1
class Case1 {
fun finally(e: Exception) {}
fun case1() {
finally(Exception())
}
}
// TESTCASE NUMBER: 2
class Case2 {
class finally(e: Exception) {}
fun case2() {
val c = finally(java.lang.Exception())
}
}
// TESTCASE NUMBER: 3
class Case3 {
fun finally() {}
fun case3() {
finally()
}
}
// TESTCASE NUMBER: 4
class Case4 {
class finally() {}
fun case4() {
val c = finally()
}
}
// TESTCASE NUMBER: 5
class Case5() {
interface finally
fun case5(){
val c = object :finally{}
}
}
@@ -0,0 +1,25 @@
// !LANGUAGE: +NewInference
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 2 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 2 -> sentence 1
* NUMBER: 1
* DESCRIPTION: catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.
*/
// TESTCASE NUMBER: 1
fun case1() {
var flag = false
try {
throw Exception()
<!UNREACHABLE_CODE!>flag = true<!>
} catch (e: Exception) {
assert(!flag)
}
}
@@ -0,0 +1,27 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 5 -> sentence 1
* RELEVANT PLACES: expressions, try-expression -> paragraph 4 -> sentence 1
* NUMBER: 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.
*/
// TESTCASE NUMBER: 1
fun case1(): String {
var flag = false
try {
flag = true
} catch (e: Exception) {
<!UNREACHABLE_CODE!>return<!> "foo"
} finally {
return "FINALLY"
}
<!UNREACHABLE_CODE!>return "return"<!>
}
@@ -0,0 +1,31 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 5 -> sentence 2
* RELEVANT PLACES: expressions, try-expression -> paragraph 4 -> sentence 1
* NUMBER: 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.
*/
/*
* TESTCASE NUMBER: 1
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-23680
*/
fun case1(): Int {
var a = 1
try {
<!UNREACHABLE_CODE!>throw<!> Exception() //invalid UNREACHABLE_CODE diagnostic
} catch (e: Exception) {
a = 5
<!UNREACHABLE_CODE!>return<!>++a
} finally {
return a
}
<!UNREACHABLE_CODE!>return 0<!>
}
@@ -0,0 +1,66 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_VARIABLE -UNUSED_PARAMETER -FINAL_UPPER_BOUND
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 8 -> sentence 1
* RELEVANT PLACES: expressions, try-expression -> paragraph 9 -> sentence 1
* NUMBER: 1
* 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
*/
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
open class A<T>(var data: T) {
fun foo(d: A<T>) {}
}
class B<T>(data: T) : A<T>(data)
// TESTCASE NUMBER: 1
fun case1() {
val tryVal: B<String> =
<!TYPE_MISMATCH, TYPE_MISMATCH!>try {
throwExceptionA(false)
A("")
} catch (e: Exception) {
B("")
}<!>
}
// TESTCASE NUMBER: 2
fun case2() {
val tryVal: A<String> =
<!TYPE_MISMATCH, TYPE_MISMATCH!>try {
throwExceptionA(false)
A("")
} catch (e: Exception) {
null
}<!>
}
/*
* TESTCASE NUMBER: 3
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-35494
*/
fun case3() {
val tryVal: A<Int> =
<!TYPE_MISMATCH, TYPE_MISMATCH!>try {
throwExceptionA(false)
A(2)
} catch (e: ExcA) {
A(<!NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!>) //diag duplication
} catch (e: ExcB) {
B(<!NULL_FOR_NONNULL_TYPE, NULL_FOR_NONNULL_TYPE!>null<!>) //diag duplication
}<!>
}
class ExcA() : Exception()
class ExcB() : Exception()
@@ -0,0 +1,70 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_EXPRESSION
// SKIP_TXT
/*
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
*
* SPEC VERSION: 0.1-218
* PLACE: expressions, try-expression -> paragraph 8 -> sentence 1
* RELEVANT PLACES: expressions, try-expression -> paragraph 9 -> sentence 1
* NUMBER: 1
* 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
* HELPERS: checkType
*/
fun throwExceptionA(b: Boolean) = run { if (b) throw ExcA() }
open class A<T>(var data: T) {}
class B<T>(data: T) : A<T>(data)
// TESTCASE NUMBER: 1
fun case1() {
val tryVal =
try {
throwExceptionA(false)
A("")
} catch (e: Exception) {
B("")
}
<!DEBUG_INFO_EXPRESSION_TYPE("A<kotlin.String>")!>tryVal<!>
tryVal checkType { check<A<kotlin.String>>() }
}
// TESTCASE NUMBER: 2
fun case2() {
val tryVal =
try {
throwExceptionA(false)
A("")
} catch (e: Exception) {
null
}
<!DEBUG_INFO_EXPRESSION_TYPE("A<kotlin.String>?")!>tryVal<!>
tryVal checkType { check<A<kotlin.String>?>() }
}
// TESTCASE NUMBER: 3
fun case3() {
val tryVal =
try {
throwExceptionA(false)
A(2)
} catch (e: ExcA) {
A(0)
} catch (e: ExcB) {
B(null)
}
<!DEBUG_INFO_EXPRESSION_TYPE("A<out kotlin.Int?>")!>tryVal<!>
tryVal checkType { check<A<out kotlin.Int?>>() }
}
class ExcA() : Exception()
class ExcB() : Exception()
@@ -0,0 +1,244 @@
{
"1": {
"neg": {
"3": [
{
"specVersion": "0.1-218",
"casesNumber": 6,
"description": "try-expression has to start with a try body and continue with zero ore more catch blocks",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 6,
"description": "try-expression has to start with a try body and continue with zero ore more catch blocks",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/3.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 3,
"description": "try-expression has to start with a try body, catch blocks and finally block",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/4.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "A valid try-expression must have at least one catch or finally block.",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/5.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 3,
"description": "try-expression has to start with a try body",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/1.1.kt",
"unexpectedBehaviour": false
}
],
"4": [
{
"specVersion": "0.1-218",
"casesNumber": 3,
"description": "try-expression has to start with a try body, catch blocks and finally block",
"unexpectedBehaviour": false
}
],
"5": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "A valid try-expression must have at least one catch or finally block.",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 3,
"description": "try-expression has to start with a try body",
"unexpectedBehaviour": false
}
]
},
"pos": {
"3": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "try-expression has to start with a try body and continue with zero ore more catch blocks",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 5,
"description": "catch is a soft keyword",
"unexpectedBehaviour": false
}
],
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "try-expression has to start with a try body and continue with zero ore more catch blocks",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/3.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "try-expression has to start with a try body, catch blocks and finally block",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/4.1.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 5,
"description": "finally is a soft keyword",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/4.2.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 5,
"description": "catch is a soft keyword",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/3.2.kt",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "try-expression has to start with a try body",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/1.1.kt",
"unexpectedBehaviour": false
}
],
"4": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "try-expression has to start with a try body, catch blocks and finally block",
"unexpectedBehaviour": false
},
{
"specVersion": "0.1-218",
"casesNumber": 5,
"description": "finally is a soft keyword",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"description": "try-expression has to start with a try body",
"unexpectedBehaviour": false
}
]
}
},
"8": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"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
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"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
}
]
}
},
"4": {
"neg": {
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 2,
"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
}
]
},
"pos": {
"1": [
{
"specVersion": "0.1-218",
"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/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
}
]
}
},
"2": {
"pos": {
"2": [
{
"specVersion": "0.1-218",
"casesNumber": 1,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"unexpectedBehaviour": false
}
],
"1": [
{
"specVersion": "0.1-218",
"casesNumber": 1,
"description": "catch block is evaluated immediately after the exception is thrown and the exception itself is passed inside the catch block as the corresponding parameter.",
"path": "compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-2/pos/2.1.kt",
"unexpectedBehaviour": false
}
]
}
},
"5": {
"pos": {
"2": [
{
"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.",
"unexpectedBehaviour": true
}
],
"1": [
{
"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.",
"unexpectedBehaviour": false
}
]
}
}
}
@@ -1509,6 +1509,219 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec {
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Try_expression extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInTry_expression() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_1 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_1() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/1.1.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/3.1.kt");
}
@TestMetadata("4.1.kt")
public void test4_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/4.1.kt");
}
@TestMetadata("5.1.kt")
public void test5_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg/5.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/neg"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/1.1.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/3.2.kt");
}
@TestMetadata("4.1.kt")
public void test4_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/4.1.kt");
}
@TestMetadata("4.2.kt")
public void test4_2() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos/4.2.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-1/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-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, this, testDataFilePath);
}
public void testAllFilesPresentInP_2() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-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, this, testDataFilePath);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-2/pos/2.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-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, this, testDataFilePath);
}
public void testAllFilesPresentInP_5() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-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, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos/1.1.kt");
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos/2.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_8 extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_8() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg/1.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/neg"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractDiagnosticsTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/pos/1.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/linked/expressions/try-expression/p-8/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1126,6 +1126,209 @@ public class BlackBoxCodegenTestSpecGenerated extends AbstractBlackBoxCodegenTes
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Try_expression extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInTry_expression() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_2 extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_2() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/neg/2.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/neg"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/2.1.kt");
}
@TestMetadata("2.2.kt")
public void test2_2() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/2.2.kt");
}
@TestMetadata("2.3.kt")
public void test2_3() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/2.3.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/3.1.kt");
}
@TestMetadata("3.2.kt")
public void test3_2() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos/3.2.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-2/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_5 extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_5() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/neg")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Neg extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/neg/3.1.kt");
}
public void testAllFilesPresentInNeg() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/neg"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/pos/1.1.kt");
}
@TestMetadata("2.1.kt")
public void test2_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/pos/2.1.kt");
}
@TestMetadata("3.1.kt")
public void test3_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/pos/3.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-5/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-6")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_6 extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_6() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-6"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-6/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-6/pos/1.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-6/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-7")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class P_7 extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInP_7() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-7"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-7/pos")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Pos extends AbstractBlackBoxCodegenTestSpec {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@TestMetadata("1.1.kt")
public void test1_1() throws Exception {
runTest("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-7/pos/1.1.kt");
}
public void testAllFilesPresentInPos() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/tests-spec/testData/codegen/box/linked/expressions/try-expression/p-7/pos"), Pattern.compile("^(.+)\\.kt$"), true);
}
}
}
}
@TestMetadata("compiler/tests-spec/testData/codegen/box/linked/expressions/type-checking-and-containment-checking-expressions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)