abb5f55087
^KT-65777 fixed
69 lines
1.9 KiB
Kotlin
Vendored
69 lines
1.9 KiB
Kotlin
Vendored
// TARGET_BACKEND: WASM
|
|
|
|
// RUN_THIRD_PARTY_OPTIMIZER
|
|
// WASM_DCE_EXPECTED_OUTPUT_SIZE: wasm 17_907
|
|
// WASM_DCE_EXPECTED_OUTPUT_SIZE: mjs 4_787
|
|
// WASM_OPT_EXPECTED_OUTPUT_SIZE: 5_841
|
|
|
|
object Simple
|
|
|
|
object SimpleWithConstVal {
|
|
const val MAX = 4
|
|
}
|
|
|
|
object SimpleWithPureProperty {
|
|
val text = "Hello"
|
|
}
|
|
|
|
object SimpleWithPropertyInitializedDurintInit {
|
|
val text: String
|
|
init {
|
|
text = "Hello"
|
|
}
|
|
}
|
|
|
|
object SimpleWithFunctionsOnly {
|
|
fun foo() = "Foo"
|
|
fun bar() = "Bar"
|
|
}
|
|
|
|
object SimpleWithDifferentMembers {
|
|
val foo = "Foo"
|
|
fun bar() = "Bar"
|
|
}
|
|
|
|
interface Callable {
|
|
fun call(): String
|
|
}
|
|
|
|
object SimpleWithInterface : Callable {
|
|
override fun call() = "OK"
|
|
}
|
|
|
|
object UsedGetFieldInside {
|
|
val anotherText = SimpleWithPureProperty.text
|
|
}
|
|
|
|
class ClassWithCompanion {
|
|
companion object
|
|
}
|
|
|
|
class ClassWithCompanionWithConst {
|
|
companion object {
|
|
const val MAX = 5
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
if (Simple !is Any) return "Fail simple object"
|
|
if (SimpleWithConstVal.MAX != 4) return "Fail simple case with const val"
|
|
if (SimpleWithPureProperty.text != "Hello") return "Fail simple case with pure property"
|
|
if (SimpleWithPropertyInitializedDurintInit.text != "Hello") return "Fail simple case with pure property initialized inside init block"
|
|
if (SimpleWithFunctionsOnly.foo() != "Foo" || SimpleWithFunctionsOnly.bar() != "Bar") return "Fail simple case with functions only"
|
|
if (SimpleWithInterface.call() != "OK") return "Fail simple case with interface implementing"
|
|
if (UsedGetFieldInside.anotherText != "Hello") return "Fail object which used another object inside its initialization block"
|
|
if (ClassWithCompanion.Companion !is Any) return "Fail simple companion object"
|
|
if (ClassWithCompanionWithConst.MAX != 5) return "Fail simple companion object with const val"
|
|
SimpleWithDifferentMembers
|
|
return "OK"
|
|
} |