Stdlib tests: annotate serialized lambdas explicitly
Behavior is going to change in KT-45375 and lambdas will no longer be serializable by default.
This commit is contained in:
committed by
Space Team
parent
07576b03c4
commit
98fb4f1f45
@@ -31,7 +31,7 @@ private class OldSchoolSingleton private constructor() : Serializable {
|
||||
class SerializableTest {
|
||||
@Test fun testClosure() {
|
||||
val tuple = Triple("Ivan", 12, Serial("serial"))
|
||||
val fn = { tuple.toString() }
|
||||
val fn = @JvmSerializableLambda { tuple.toString() }
|
||||
val deserialized = serializeAndDeserialize(fn)
|
||||
|
||||
assertEquals(fn(), deserialized())
|
||||
@@ -39,8 +39,8 @@ class SerializableTest {
|
||||
|
||||
@Test fun testComplexClosure() {
|
||||
val y = 12
|
||||
val fn1 = { x: Int -> (x + y).toString() }
|
||||
val fn2: Int.(Int) -> String = { fn1(this + it) }
|
||||
val fn1 = @JvmSerializableLambda { x: Int -> (x + y).toString() }
|
||||
val fn2: Int.(Int) -> String = @JvmSerializableLambda { fn1(this + it) }
|
||||
val deserialized = serializeAndDeserialize(fn2)
|
||||
|
||||
assertEquals(5.fn2(10), 5.deserialized(10))
|
||||
|
||||
Reference in New Issue
Block a user