[PL][tests] Keep PL test data under "testData/klib/" dir

This commit is contained in:
Dmitriy Dolovov
2023-08-15 14:38:02 +02:00
committed by Space Team
parent 9e3afe7a1f
commit 5c3e63e19a
186 changed files with 156 additions and 156 deletions
@@ -0,0 +1,15 @@
class Class {
fun f() = "FAIL: Class.f"
val p get() = "FAIL: Class.p"
override fun toString() = "FAIL: Class.toString"
}
class RemovedClass {
fun f() = "FAIL: RemovedClass.f"
val p get() = "FAIL: RemovedClass.p"
}
abstract class RemovedAbstractClass
interface RemovedInterface
open class RemovedOpenClass
@@ -0,0 +1,15 @@
class Class {
fun f() = "Class.f"
val p get() = "Class.p"
override fun toString() = "Class"
}
//class RemovedClass {
// fun f() = "FAIL: RemovedClass.f"
// val p get() = "FAIL: RemovedClass.p"
//}
//abstract class RemovedAbstractClass
//interface RemovedInterface
//open class RemovedOpenClass
@@ -0,0 +1,6 @@
STEP 0:
dependencies: stdlib
STEP 1:
dependencies: stdlib
modifications:
U : l1.kt.1 -> l1.kt
@@ -0,0 +1,278 @@
@file:Suppress("NOTHING_TO_INLINE")
fun createRemovedClass() {
check(RemovedClass().toString() != "Yellow Submarine")
}
interface Interface<T> {
val value: T
}
class InterfaceImplParameterizedByClass : Interface<Class> {
override val value: Class = Class()
}
class InterfaceImplParameterizedByRemovedClass: Interface<RemovedClass> {
override val value: RemovedClass = TODO()
}
class Checker {
fun useClassAsValueParameter(c: Class): String = "Checker.useClassAsValueParameter($c)"
fun createAndPassClassAsValueParameter(): String = useClassAsValueParameter(Class())
fun useRemovedClassAsValueParameter(@Suppress("UNUSED_PARAMETER") e: RemovedClass?): String = "FAIL: useRemovedClassAsValueParameter"
fun createAndPassRemovedClassAsValueParameter(): String = useRemovedClassAsValueParameter(null)
var removedClassProperty: RemovedClass? = null
protected set(_) { /* Do nothing */ }
fun writeToRemovedClassProperty(): String {
removedClassProperty = null
return "FAIL: writeToRemovedClassProperty"
}
fun createClass(): Class = Class()
fun createClassAndCallFunction(): String = createClass().f()
val getClass1: Class get() = Class()
val getClassAndReadProperty1: String get() = getClass1.p
val getClass2: Class = Class()
val getClassAndReadProperty2: String = getClass2.p
fun createRemovedClass(): RemovedClass = TODO()
fun createRemovedClassAndCallFunction(): String = createRemovedClass().f()
val getRemovedClass: RemovedClass get() = TODO()
val getRemovedClassAndReadProperty: String get() = getRemovedClass.p
class CrashesOnCreation {
val getRemovedClass: RemovedClass = TODO()
val getRemovedClassAndReadBar: String = getRemovedClass.p
}
fun createInterfaceImplParameterizedByClass(): Interface<Class> = InterfaceImplParameterizedByClass()
fun createInterfaceImplParameterizedByClassAndCallFunction(): String = createInterfaceImplParameterizedByClass().value.f()
fun createInstanceImplParameterizedByRemovedClass(): Interface<RemovedClass> = InterfaceImplParameterizedByRemovedClass()
fun createInstanceImplParameterizedByRemovedClassAndCallFunction(): String = createInstanceImplParameterizedByRemovedClass().value.f()
}
fun readVariableInFunction() {
var removed: RemovedClass? = null
check(removed == null)
}
fun writeVariableInFunction() {
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE", "CanBeVal") var removed: RemovedClass?
@Suppress("UNUSED_VALUE")
removed = null
}
fun readVariableInLocalFunction() {
fun local() {
var removed: RemovedClass? = null
check(removed == null)
}
local()
}
fun writeVariableInLocalFunction() {
fun local() {
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE", "CanBeVal") var removed: RemovedClass?
@Suppress("UNUSED_VALUE")
removed = null
}
local()
}
fun readVariableInLocalClass() {
class Local {
fun foo() {
var removed: RemovedClass? = null
check(removed == null)
}
}
Local().foo()
}
fun writeVariableInLocalClass() {
class Local {
fun foo() {
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE", "CanBeVal") var removed: RemovedClass?
@Suppress("UNUSED_VALUE")
removed = null
}
}
Local().foo()
}
fun readVariableInAnonymousObject() {
object {
fun foo() {
var removed: RemovedClass? = null
check(removed == null)
}
}.foo()
}
fun writeVariableInAnonymousObject() {
object {
fun foo() {
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE", "CanBeVal") var removed: RemovedClass?
@Suppress("UNUSED_VALUE")
removed = null
}
}.foo()
}
fun readVariableInAnonymousObjectThroughLocalVar() {
val obj = object {
fun foo() {
var removed: RemovedClass? = null
check(removed == null)
}
}
obj.foo()
}
fun writeVariableInAnonymousObjectThroughLocalVar() {
val obj = object {
fun foo() {
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE", "CanBeVal") var removed: RemovedClass?
@Suppress("UNUSED_VALUE")
removed = null
}
}
obj.foo()
}
fun callLocalFunction() {
fun local(): RemovedClass = TODO()
local()
}
fun callLocalFunctionInLocalFunction() {
fun local() {
fun local(): RemovedClass = TODO()
local()
}
local()
}
fun callLocalFunctionInFunctionOfLocalClass() {
class Local {
fun foo() {
fun local(): RemovedClass = TODO()
local()
}
}
Local().foo()
}
fun callLocalFunctionInFunctionOfAnonymousObject() {
object {
fun foo() {
fun local(): RemovedClass = TODO()
local()
}
}.foo()
}
fun callLocalFunctionInFunctionOfAnonymousObjectThroughLocalVar() {
val obj = object {
fun foo() {
fun local(): RemovedClass = TODO()
local()
}
}
obj.foo()
}
class TopLevelClassChildOfRemovedAbstractClass : RemovedAbstractClass()
object TopLevelObjectChildOfRemovedAbstractClass : RemovedAbstractClass()
interface TopLevelInterfaceChildOfRemovedInterface : RemovedInterface
class TopLevelClassChildOfRemovedInterface : RemovedInterface
object TopLevelObjectChildOfRemovedInterface : RemovedInterface
enum class TopLevelEnumClassChildOfRemovedInterface : RemovedInterface { ENTRY }
class TopLevel {
class NestedClassChildOfRemovedAbstractClass : RemovedAbstractClass()
object NestedObjectChildOfRemovedAbstractClass : RemovedAbstractClass()
interface NestedInterfaceChildOfRemovedInterface : RemovedInterface
class NestedClassChildOfRemovedInterface : RemovedInterface
object NestedObjectChildOfRemovedInterface : RemovedInterface
enum class NestedEnumClassChildOfRemovedInterface : RemovedInterface { ENTRY }
inner class InnerClassChildOfRemovedAbstractClass : RemovedAbstractClass()
inner class InnerClassChildOfRemovedInterface : RemovedInterface
}
class TopLevelWithCompanionChildOfRemovedAbstractClass {
companion object : RemovedAbstractClass()
}
class TopLevelWithCompanionChildOfRemovedInterface {
companion object : RemovedInterface
}
val anonymousObjectChildOfRemovedAbstractClass = object : RemovedAbstractClass() {}
val anonymousObjectChildOfRemovedInterface = object : RemovedInterface {}
fun topLevelFunctionWithLocalClassChildOfRemovedAbstractClass() {
class LocalClass : RemovedAbstractClass()
LocalClass().toString()
}
fun topLevelFunctionWithLocalClassChildOfRemovedInterface() {
class LocalClass : RemovedInterface
LocalClass().toString()
}
fun topLevelFunctionWithAnonymousObjectChildOfRemovedAbstractClass() {
val anonymousObject = object : RemovedAbstractClass() {}
anonymousObject.toString()
}
fun topLevelFunctionWithAnonymousObjectChildOfRemovedInterface() {
val anonymousObject = object : RemovedInterface {}
anonymousObject.toString()
}
open class OpenClassImpl : RemovedOpenClass()
inline fun inlinedFunctionWithRemovedOpenClassVariableType() {
val foo: RemovedOpenClass? = null
check(foo == null)
}
inline fun inlinedFunctionWithOpenClassImplVariableType() {
val foo: OpenClassImpl? = null
check(foo == null)
}
inline fun inlinedFunctionWithCreationOfRemovedOpenClass() {
check(RemovedOpenClass().toString() != "Yellow Submarine")
}
inline fun inlinedFunctionWithCreationOfOpenClassImpl() {
check(OpenClassImpl().toString() != "Yellow Submarine")
}
inline fun inlinedFunctionWithCreationOfRemovedOpenClassThroughReference() {
check(run(::RemovedOpenClass).toString() != "Yellow Submarine")
}
inline fun inlinedFunctionWithCreationOfOpenClassImplThroughReference() {
check(run(::OpenClassImpl).toString() != "Yellow Submarine")
}
inline fun inlinedFunctionWithRemovedOpenClassAnonymousObject() {
val foo = object : RemovedOpenClass() {}
check(foo.toString().isNotEmpty())
}
inline fun inlinedFunctionWithOpenClassImplAnonymousObject() {
val foo = object : OpenClassImpl() {}
check(foo.toString().isNotEmpty())
}
@@ -0,0 +1,2 @@
STEP 0:
dependencies: stdlib, lib1
@@ -0,0 +1,70 @@
import abitestutils.abiTest
fun box() = abiTest {
val checker = Checker()
expectFailure(linkage("Constructor 'RemovedClass.<init>' can not be called: No constructor found for symbol '/RemovedClass.<init>'")) { createRemovedClass() }
expectFailure(linkage("Function 'useRemovedClassAsValueParameter' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { checker.createAndPassRemovedClassAsValueParameter() }
expectFailure(linkage("Property accessor 'removedClassProperty.<set-removedClassProperty>' can not be called: Property accessor uses unlinked class symbol '/RemovedClass'")) { checker.writeToRemovedClassProperty() }
expectSuccess("Checker.useClassAsValueParameter(Class)") { checker.createAndPassClassAsValueParameter() }
expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInFunction() }
expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInFunction() }
expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInLocalFunction() }
expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInLocalFunction() }
expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInLocalClass() }
expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInLocalClass() }
expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInAnonymousObject() }
expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInAnonymousObject() }
expectFailure(linkage("Can not read value from variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { readVariableInAnonymousObjectThroughLocalVar() }
expectFailure(linkage("Can not write value to variable 'removed': Variable uses unlinked class symbol '/RemovedClass'")) { writeVariableInAnonymousObjectThroughLocalVar() }
expectFailure(linkage("Function 'createRemovedClass' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { checker.createRemovedClassAndCallFunction() }
expectFailure(linkage("Property accessor 'getRemovedClass.<get-getRemovedClass>' can not be called: Property accessor uses unlinked class symbol '/RemovedClass'")) { checker.getRemovedClassAndReadProperty }
expectSuccess("Class.f") { checker.createClassAndCallFunction() }
expectSuccess("Class.p") { checker.getClassAndReadProperty1 }
expectSuccess("Class.p") { checker.getClassAndReadProperty2 }
expectFailure(linkage("Property accessor 'getRemovedClass.<get-getRemovedClass>' can not be called: Property accessor uses unlinked class symbol '/RemovedClass'")) { Checker.CrashesOnCreation() }
expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunction() }
expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInLocalFunction() }
expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInFunctionOfLocalClass() }
expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInFunctionOfAnonymousObject() }
expectFailure(linkage("Function 'local' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { callLocalFunctionInFunctionOfAnonymousObjectThroughLocalVar() }
expectFailure(linkage("Function 'createInstanceImplParameterizedByRemovedClass' can not be called: Function uses unlinked class symbol '/RemovedClass'")) { checker.createInstanceImplParameterizedByRemovedClassAndCallFunction() }
expectSuccess("Class.f") { checker.createInterfaceImplParameterizedByClassAndCallFunction() }
expectFailure(linkage("Constructor 'TopLevelClassChildOfRemovedAbstractClass.<init>' can not be called: Class 'TopLevelClassChildOfRemovedAbstractClass' uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevelClassChildOfRemovedAbstractClass() }
expectFailure(linkage("Can not get instance of singleton 'TopLevelObjectChildOfRemovedAbstractClass': Expression uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevelObjectChildOfRemovedAbstractClass }
expectFailure(linkage("Constructor '<init>' can not be called: Anonymous object uses unlinked class symbol '/RemovedInterface'")) { object : TopLevelInterfaceChildOfRemovedInterface {} }
expectFailure(linkage("Constructor 'TopLevelClassChildOfRemovedInterface.<init>' can not be called: Class 'TopLevelClassChildOfRemovedInterface' uses unlinked class symbol '/RemovedInterface'")) { TopLevelClassChildOfRemovedInterface() }
expectFailure(linkage("Can not get instance of singleton 'TopLevelObjectChildOfRemovedInterface': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevelObjectChildOfRemovedInterface }
expectFailure(linkage("Can not get instance of singleton 'TopLevelEnumClassChildOfRemovedInterface.ENTRY': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevelEnumClassChildOfRemovedInterface.ENTRY }
expectFailure(linkage("Constructor 'NestedClassChildOfRemovedAbstractClass.<init>' can not be called: Class 'NestedClassChildOfRemovedAbstractClass' uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevel.NestedClassChildOfRemovedAbstractClass() }
expectFailure(linkage("Can not get instance of singleton 'NestedObjectChildOfRemovedAbstractClass': Expression uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevel.NestedObjectChildOfRemovedAbstractClass }
expectFailure(linkage("Constructor '<init>' can not be called: Anonymous object uses unlinked class symbol '/RemovedInterface'")) { object : TopLevel.NestedInterfaceChildOfRemovedInterface {} }
expectFailure(linkage("Constructor 'NestedClassChildOfRemovedInterface.<init>' can not be called: Class 'NestedClassChildOfRemovedInterface' uses unlinked class symbol '/RemovedInterface'")) { TopLevel.NestedClassChildOfRemovedInterface() }
expectFailure(linkage("Can not get instance of singleton 'NestedObjectChildOfRemovedInterface': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevel.NestedObjectChildOfRemovedInterface }
expectFailure(linkage("Can not get instance of singleton 'NestedEnumClassChildOfRemovedInterface.ENTRY': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevel.NestedEnumClassChildOfRemovedInterface.ENTRY }
expectFailure(linkage("Constructor 'InnerClassChildOfRemovedAbstractClass.<init>' can not be called: Inner class 'InnerClassChildOfRemovedAbstractClass' uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevel().InnerClassChildOfRemovedAbstractClass() }
expectFailure(linkage("Constructor 'InnerClassChildOfRemovedInterface.<init>' can not be called: Inner class 'InnerClassChildOfRemovedInterface' uses unlinked class symbol '/RemovedInterface'")) { TopLevel().InnerClassChildOfRemovedInterface() }
expectFailure(linkage("Can not get instance of singleton 'TopLevelWithCompanionChildOfRemovedAbstractClass.Companion': Expression uses unlinked class symbol '/RemovedAbstractClass'")) { TopLevelWithCompanionChildOfRemovedAbstractClass.Companion }
expectFailure(linkage("Can not get instance of singleton 'TopLevelWithCompanionChildOfRemovedInterface.Companion': Expression uses unlinked class symbol '/RemovedInterface'")) { TopLevelWithCompanionChildOfRemovedInterface.Companion }
expectFailure(linkage("Property accessor 'anonymousObjectChildOfRemovedAbstractClass.<get-anonymousObjectChildOfRemovedAbstractClass>' can not be called: Property accessor uses unlinked class symbol '/RemovedAbstractClass'")) { anonymousObjectChildOfRemovedAbstractClass }
expectFailure(linkage("Property accessor 'anonymousObjectChildOfRemovedInterface.<get-anonymousObjectChildOfRemovedInterface>' can not be called: Property accessor uses unlinked class symbol '/RemovedInterface'")) { anonymousObjectChildOfRemovedInterface }
expectFailure(linkage("Constructor 'LocalClass.<init>' can not be called: Class 'LocalClass' uses unlinked class symbol '/RemovedAbstractClass'")) { topLevelFunctionWithLocalClassChildOfRemovedAbstractClass() }
expectFailure(linkage("Constructor 'LocalClass.<init>' can not be called: Class 'LocalClass' uses unlinked class symbol '/RemovedInterface'")) { topLevelFunctionWithLocalClassChildOfRemovedInterface() }
expectFailure(linkage("Can not read value from variable 'anonymousObject': Variable uses unlinked class symbol '/RemovedAbstractClass' (via anonymous object)")) { topLevelFunctionWithAnonymousObjectChildOfRemovedAbstractClass() }
expectFailure(linkage("Can not read value from variable 'anonymousObject': Variable uses unlinked class symbol '/RemovedInterface' (via anonymous object)")) { topLevelFunctionWithAnonymousObjectChildOfRemovedInterface() }
expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass'")) { inlinedFunctionWithRemovedOpenClassVariableType() }
expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass' (via class 'OpenClassImpl')")) { inlinedFunctionWithOpenClassImplVariableType() }
expectFailure(linkage("Constructor 'RemovedOpenClass.<init>' can not be called: No constructor found for symbol '/RemovedOpenClass.<init>'")) { inlinedFunctionWithCreationOfRemovedOpenClass() }
expectFailure(linkage("Constructor 'OpenClassImpl.<init>' can not be called: Class 'OpenClassImpl' uses unlinked class symbol '/RemovedOpenClass'")) { inlinedFunctionWithCreationOfOpenClassImpl() }
expectFailure(linkage("Reference to constructor 'RemovedOpenClass.<init>' can not be evaluated: No constructor found for symbol '/RemovedOpenClass.<init>'")) { inlinedFunctionWithCreationOfRemovedOpenClassThroughReference() }
expectFailure(linkage("Reference to constructor 'OpenClassImpl.<init>' can not be evaluated: Class 'OpenClassImpl' uses unlinked class symbol '/RemovedOpenClass'")) { inlinedFunctionWithCreationOfOpenClassImplThroughReference() }
expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass' (via anonymous object)")) { inlinedFunctionWithRemovedOpenClassAnonymousObject() }
expectFailure(linkage("Can not read value from variable 'foo': Variable uses unlinked class symbol '/RemovedOpenClass' (via anonymous object)")) { inlinedFunctionWithOpenClassImplAnonymousObject() }
}
@@ -0,0 +1,2 @@
STEP 0:
dependencies: stdlib, lib1, lib2
@@ -0,0 +1,7 @@
MODULES: lib1, lib2, main
STEP 0:
libs: lib1, lib2, main
STEP 1:
libs: lib1