Minor. Add test
This commit is contained in:
Generated
+5
@@ -8343,6 +8343,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_3() throws Exception {
|
public void testKt19475_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
||||||
|
|||||||
+149
@@ -0,0 +1,149 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
interface Scope
|
||||||
|
|
||||||
|
fun <T> doTest(
|
||||||
|
coroutineContext: CoroutineContext,
|
||||||
|
timeout: Long = 10000L,
|
||||||
|
action: suspend Scope.() -> T
|
||||||
|
): T = TODO()
|
||||||
|
|
||||||
|
object Dispatcher : CoroutineContext {
|
||||||
|
override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E? {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext {
|
||||||
|
TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Cache {
|
||||||
|
suspend fun getOrPutByString(str: String, put: suspend () -> Info): Info = TODO()
|
||||||
|
suspend fun getOrPutById(id: ID, put: suspend () -> Info): Info = TODO()
|
||||||
|
suspend fun removeById(id: ID, newValue: Info? = null) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Info(val str: String)
|
||||||
|
|
||||||
|
typealias ID = String
|
||||||
|
|
||||||
|
private val Info.id get() = ""
|
||||||
|
|
||||||
|
inline fun expectAnyFailure(failureMessage: String? = null, action: () -> Unit) {
|
||||||
|
expectFailure<Throwable>(failureMessage) {
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoggedErrors {
|
||||||
|
var disabled = false
|
||||||
|
|
||||||
|
val disabledTypes = mutableSetOf<String?>()
|
||||||
|
}
|
||||||
|
|
||||||
|
class AtomicReference<T>(var value: T) {
|
||||||
|
fun get(): T = TODO()
|
||||||
|
}
|
||||||
|
|
||||||
|
object Expector {
|
||||||
|
val currentErrors = AtomicReference<LoggedErrors?>(null)
|
||||||
|
|
||||||
|
inline fun <T> disable(action: () -> T) {
|
||||||
|
currentErrors.get()?.apply {
|
||||||
|
val oldValue = disabled
|
||||||
|
disabled = true
|
||||||
|
try {
|
||||||
|
action()
|
||||||
|
} finally {
|
||||||
|
disabled = oldValue
|
||||||
|
}
|
||||||
|
} ?: action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <reified E : Throwable> expectFailure(
|
||||||
|
failureMessage: String? = null,
|
||||||
|
noinline exceptionCheck: ((E) -> Unit)? = null,
|
||||||
|
action: () -> Unit
|
||||||
|
) {
|
||||||
|
var exceptionWasThrown = false
|
||||||
|
try {
|
||||||
|
Expector.disable {
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
} catch (ex: Throwable) {
|
||||||
|
exceptionWasThrown = true
|
||||||
|
// Exception is expected.
|
||||||
|
assertTrue("'${ex::class}' was thrown.", ex is E)
|
||||||
|
exceptionCheck?.invoke(ex as E)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exceptionWasThrown) {
|
||||||
|
fail("No exception was thrown.${failureMessage?.let { " $it" } ?: ""}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertEquals(expected: Any?, actual: Any?) {}
|
||||||
|
fun fail(message: String) {
|
||||||
|
error(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertTrue(message: String, value: Boolean) {}
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
private val i1 = Info("1")
|
||||||
|
private val i2 = Info("2")
|
||||||
|
fun test() {
|
||||||
|
doTest(Dispatcher) {
|
||||||
|
val cache = Cache()
|
||||||
|
|
||||||
|
cache.getOrPutByString(i1.str) { i1 }
|
||||||
|
|
||||||
|
assertEquals(i1, cache.getByString(i1.str.toLowerCase()))
|
||||||
|
assertEquals(i1, cache.getByString(i1.str.toUpperCase()))
|
||||||
|
assertEquals(i1, cache.getById(i1.id))
|
||||||
|
expectAnyFailure { cache.getByString(i2.str.toLowerCase()) }
|
||||||
|
expectAnyFailure { cache.getByString(i2.str.toUpperCase()) }
|
||||||
|
expectAnyFailure { cache.getById(i2.id) }
|
||||||
|
|
||||||
|
cache.removeById(i2.id)
|
||||||
|
|
||||||
|
assertEquals(i1, cache.getByString(i1.str.toLowerCase()))
|
||||||
|
assertEquals(i1, cache.getByString(i1.str.toUpperCase()))
|
||||||
|
assertEquals(i1, cache.getById(i1.id))
|
||||||
|
expectAnyFailure { cache.getByString(i2.str.toLowerCase()) }
|
||||||
|
expectAnyFailure { cache.getByString(i2.str.toUpperCase()) }
|
||||||
|
expectAnyFailure { cache.getById(i2.id) }
|
||||||
|
|
||||||
|
cache.removeById(i1.id)
|
||||||
|
|
||||||
|
expectAnyFailure { cache.getByString(i1.str.toLowerCase()) }
|
||||||
|
expectAnyFailure { cache.getByString(i1.str.toUpperCase()) }
|
||||||
|
expectAnyFailure { cache.getById(i1.id) }
|
||||||
|
expectAnyFailure { cache.getByString(i2.str.toLowerCase()) }
|
||||||
|
expectAnyFailure { cache.getByString(i2.str.toUpperCase()) }
|
||||||
|
expectAnyFailure { cache.getById(i2.id) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun Cache.getByString(str: String) =
|
||||||
|
getOrPutByString(str) { error("Not found $str") }
|
||||||
|
|
||||||
|
private suspend fun Cache.getById(id: ID) =
|
||||||
|
getOrPutById(id) { error("Not found $id") }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
// This is compiler sanity tests
|
||||||
|
Test()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -9553,6 +9553,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_2() throws Exception {
|
public void testKt19475_1_2() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines.experimental");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines.experimental");
|
||||||
|
|||||||
+5
@@ -9553,6 +9553,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_2() throws Exception {
|
public void testKt19475_1_2() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines.experimental");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines.experimental");
|
||||||
|
|||||||
+5
@@ -8343,6 +8343,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_3() throws Exception {
|
public void testKt19475_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
||||||
|
|||||||
Generated
+5
@@ -7068,6 +7068,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_3() throws Exception {
|
public void testKt19475_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
||||||
|
|||||||
Generated
+5
@@ -7078,6 +7078,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_3() throws Exception {
|
public void testKt19475_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
||||||
|
|||||||
+5
@@ -7078,6 +7078,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/varSpilling"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fakeInlinerVariables.kt")
|
||||||
|
public void testFakeInlinerVariables() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/varSpilling/fakeInlinerVariables.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt19475.kt")
|
@TestMetadata("kt19475.kt")
|
||||||
public void testKt19475_1_3() throws Exception {
|
public void testKt19475_1_3() throws Exception {
|
||||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/varSpilling/kt19475.kt", "kotlin.coroutines");
|
||||||
|
|||||||
Reference in New Issue
Block a user