c7435ba760
We are going to deprecate `WITH_RUNTIME` directive. The main reason behind this change is that `WITH_STDLIB` directive better describes its meaning, specifically it will add kotlin stdlib to test's classpath.
30 lines
683 B
Kotlin
Vendored
30 lines
683 B
Kotlin
Vendored
// WITH_STDLIB
|
|
|
|
@file:JvmName("TestKt")
|
|
package test
|
|
|
|
import kotlinx.android.parcel.*
|
|
import android.os.Parcel
|
|
import android.os.Parcelable
|
|
|
|
fun box() = doTest { creator ->
|
|
assert(creator.newArray(5) != null)
|
|
}
|
|
|
|
fun doTest(work: (Parcelable.Creator<DummyParcelable>) -> Unit): String {
|
|
val dummy = DummyParcelable(42)
|
|
|
|
val clazz = dummy.javaClass
|
|
val field = clazz.getDeclaredField("CREATOR")
|
|
val creator = field.get(dummy) as Parcelable.Creator<DummyParcelable>
|
|
|
|
val parcel = Parcel.obtain()
|
|
dummy.writeToParcel(parcel, 0)
|
|
parcel.setDataPosition(0)
|
|
|
|
work(creator)
|
|
return "OK"
|
|
}
|
|
|
|
@Parcelize
|
|
data class DummyParcelable(val int: Int): Parcelable |