[K/N][Tests] Move codegen test sources interfaceCallsNCasts..vector
^KT-61259
This commit is contained in:
committed by
Space Team
parent
56e1c5cbc6
commit
93642020ff
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.catch3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
try {
|
||||
println("Before")
|
||||
throw Error("Error happens")
|
||||
println("After")
|
||||
} catch (e: Throwable) {
|
||||
println("Caught Throwable")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Before
|
||||
Caught Throwable
|
||||
Done
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.catch4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
try {
|
||||
println("Before")
|
||||
throw Error("Error happens")
|
||||
println("After")
|
||||
} catch (e: Exception) {
|
||||
println("Caught Exception")
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
} catch (e: Throwable) {
|
||||
println("Caught Throwable")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Before
|
||||
Caught Error
|
||||
Done
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.catch5
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
try {
|
||||
try {
|
||||
println("Before")
|
||||
foo()
|
||||
println("After")
|
||||
} catch (e: Exception) {
|
||||
println("Caught Exception")
|
||||
}
|
||||
|
||||
println("After nested try")
|
||||
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
} catch (e: Throwable) {
|
||||
println("Caught Throwable")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
throw Error("Error happens")
|
||||
println("After in foo()")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Before
|
||||
Caught Error
|
||||
Done
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.catch6
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
try {
|
||||
println("Before")
|
||||
foo()
|
||||
println("After")
|
||||
} catch (e: Exception) {
|
||||
println("Caught Exception")
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
try {
|
||||
throw Error("Error happens")
|
||||
} catch (e: Exception) {
|
||||
println("Caught Exception")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Before
|
||||
Caught Error
|
||||
Done
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.catch8
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
try {
|
||||
throw Error("Error happens")
|
||||
} catch (e: Throwable) {
|
||||
val message = e.message
|
||||
if (message != null) {
|
||||
println(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Error happens
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
try {
|
||||
println("Try")
|
||||
} finally {
|
||||
println("Finally")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Try
|
||||
Finally
|
||||
Done
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally10
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
while (true) {
|
||||
try {
|
||||
continue
|
||||
} finally {
|
||||
println("Finally")
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
println("After")
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Finally
|
||||
After
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally11
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
try {
|
||||
try {
|
||||
return
|
||||
} catch (e: Error) {
|
||||
println("Catch 1")
|
||||
} finally {
|
||||
println("Finally")
|
||||
throw Error()
|
||||
}
|
||||
} catch (e: Error) {
|
||||
println("Catch 2")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Finally
|
||||
Catch 2
|
||||
Done
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
try {
|
||||
println("Try")
|
||||
throw Error("Error happens")
|
||||
println("After throw")
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
} finally {
|
||||
println("Finally")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Try
|
||||
Caught Error
|
||||
Finally
|
||||
Done
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
try {
|
||||
try {
|
||||
println("Try")
|
||||
throw Error("Error happens")
|
||||
println("After throw")
|
||||
} finally {
|
||||
println("Finally")
|
||||
}
|
||||
|
||||
println("After nested try")
|
||||
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Try
|
||||
Finally
|
||||
Caught Error
|
||||
Done
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
|
||||
try {
|
||||
try {
|
||||
println("Try")
|
||||
throw Error("Error happens")
|
||||
println("After throw")
|
||||
} catch (e: Error) {
|
||||
println("Catch")
|
||||
throw Exception()
|
||||
println("After throw")
|
||||
} finally {
|
||||
println("Finally")
|
||||
}
|
||||
|
||||
println("After nested try")
|
||||
|
||||
} catch (e: Error) {
|
||||
println("Caught Error")
|
||||
} catch (e: Exception) {
|
||||
println("Caught Exception")
|
||||
}
|
||||
|
||||
println("Done")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Try
|
||||
Catch
|
||||
Finally
|
||||
Caught Exception
|
||||
Done
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally5
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
println(foo())
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
try {
|
||||
println("Done")
|
||||
return 0
|
||||
} finally {
|
||||
println("Finally")
|
||||
}
|
||||
|
||||
println("After")
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Done
|
||||
Finally
|
||||
0
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally6
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
println(foo())
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
try {
|
||||
println("Done")
|
||||
return 0
|
||||
} finally {
|
||||
println("Finally")
|
||||
return 1
|
||||
}
|
||||
|
||||
println("After")
|
||||
return 2
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Done
|
||||
Finally
|
||||
1
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally7
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
println(foo())
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
try {
|
||||
println("Done")
|
||||
throw Error()
|
||||
} finally {
|
||||
println("Finally")
|
||||
return 1
|
||||
}
|
||||
|
||||
println("After")
|
||||
return 2
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Done
|
||||
Finally
|
||||
1
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally8
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
println(foo())
|
||||
}
|
||||
|
||||
fun foo(): Int {
|
||||
try {
|
||||
try {
|
||||
return 42
|
||||
} finally {
|
||||
println("Finally 1")
|
||||
}
|
||||
} finally {
|
||||
println("Finally 2")
|
||||
}
|
||||
|
||||
println("After")
|
||||
return 2
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Finally 1
|
||||
Finally 2
|
||||
42
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.finally9
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
do {
|
||||
try {
|
||||
break
|
||||
} finally {
|
||||
println("Finally 1")
|
||||
}
|
||||
} while (false)
|
||||
|
||||
var stop = false
|
||||
while (!stop) {
|
||||
try {
|
||||
stop = true
|
||||
continue
|
||||
} finally {
|
||||
println("Finally 2")
|
||||
}
|
||||
}
|
||||
|
||||
println("After")
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
Finally 1
|
||||
Finally 2
|
||||
After
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.returnsDifferentTypes
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
class ReceiveChannel<out E>
|
||||
|
||||
inline fun <E, R> ReceiveChannel<E>.consume(block: ReceiveChannel<E>.() -> R): R {
|
||||
try {
|
||||
return block()
|
||||
}
|
||||
finally {
|
||||
println("zzz")
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <E> ReceiveChannel<E>.elementAtOrElse(index: Int, defaultValue: (Int) -> E): E =
|
||||
consume {
|
||||
if (index < 0)
|
||||
return defaultValue(index)
|
||||
return 42 as E
|
||||
}
|
||||
|
||||
fun <E> ReceiveChannel<E>.elementAt(index: Int): E =
|
||||
elementAtOrElse(index) { throw IndexOutOfBoundsException("qxx") }
|
||||
|
||||
@Test fun runTest() {
|
||||
println(ReceiveChannel<Int>().elementAt(0))
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
zzz
|
||||
42
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.try1
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val x = try {
|
||||
5
|
||||
} catch (e: Throwable) {
|
||||
6
|
||||
}
|
||||
|
||||
println(x)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
5
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.try2
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val x = try {
|
||||
throw Error()
|
||||
5
|
||||
} catch (e: Throwable) {
|
||||
6
|
||||
}
|
||||
|
||||
println(x)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
6
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.try3
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val x = try {
|
||||
throw Error()
|
||||
} catch (e: Throwable) {
|
||||
6
|
||||
}
|
||||
|
||||
println(x)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
6
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 file.
|
||||
*/
|
||||
|
||||
package codegen.`try`.try4
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@Test fun runTest() {
|
||||
val x = try {
|
||||
println("Try")
|
||||
5
|
||||
} catch (e: Throwable) {
|
||||
throw e
|
||||
}
|
||||
|
||||
println(x)
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Try
|
||||
5
|
||||
Reference in New Issue
Block a user