Parcelize: Add test for KT-26221
This commit is contained in:
committed by
Alexander Udalov
parent
1552e55474
commit
01ea2a641f
+5
@@ -129,6 +129,11 @@ public class ParcelBoxTestGenerated extends AbstractParcelBoxTest {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/kt25839.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt26221.kt")
|
||||
public void testKt26221() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/kt26221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("listKinds.kt")
|
||||
public void testListKinds() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/listKinds.kt");
|
||||
|
||||
+5
@@ -129,6 +129,11 @@ public class ParcelIrBoxTestGenerated extends AbstractParcelIrBoxTest {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/kt25839.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt26221.kt")
|
||||
public void testKt26221() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/kt26221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("listKinds.kt")
|
||||
public void testListKinds() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-compiler/testData/parcel/box/listKinds.kt");
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// Fails with a VerifyError in Foo.writeToParcel
|
||||
// WITH_RUNTIME
|
||||
|
||||
@file:JvmName("TestKt")
|
||||
package test
|
||||
|
||||
import kotlinx.android.parcel.*
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.util.SparseArray
|
||||
|
||||
@Parcelize
|
||||
data class PInt(val x: Int) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class Foo(val values: SparseArray<SparseArray<Parcelable>>) : Parcelable
|
||||
|
||||
fun box() = parcelTest { parcel ->
|
||||
val pint = PInt(0)
|
||||
val sarray = SparseArray<Parcelable>()
|
||||
sarray.put(0, pint)
|
||||
val sarray2 = SparseArray<SparseArray<Parcelable>>()
|
||||
sarray2.put(1, sarray)
|
||||
val foo = Foo(sarray2)
|
||||
|
||||
foo.writeToParcel(parcel, 0)
|
||||
|
||||
val bytes = parcel.marshall()
|
||||
parcel.unmarshall(bytes, 0, bytes.size)
|
||||
|
||||
val foo2 = readFromParcel<Foo>(parcel)
|
||||
assert(foo2.values.size() == 1)
|
||||
assert(foo2.values.get(1) != null) // SparseArray.contains was only added in Android R
|
||||
assert(foo2.values.get(1).size() == 1)
|
||||
assert(foo2.values.get(1).get(0) != null)
|
||||
assert(foo2.values.get(1).get(0) == pint)
|
||||
}
|
||||
Reference in New Issue
Block a user