You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Old one used time-based approach. It was a good indicator, but in rare circumstances it may have been flaky and produced incorrect results. Flaky time-based tests are problematic for large builds, such as Kotlin's Aggregate build.
New approach is based on cache presence and should not give incorrect results.
See also #KTI-1726
Copy file name to clipboardExpand all lines: core/jvmTest/src/kotlinx/serialization/CachingTest.kt
+18-1Lines changed: 18 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ package kotlinx.serialization
6
6
7
7
importkotlinx.serialization.internal.*
8
8
importkotlinx.serialization.modules.*
9
-
importorg.junit.Test
10
9
importkotlin.reflect.*
11
10
importkotlin.test.*
11
+
importkotlin.test.Test
12
12
13
13
classCachingTest {
14
14
@Test
@@ -43,4 +43,21 @@ class CachingTest {
43
43
44
44
assertEquals(1, factoryCalled)
45
45
}
46
+
47
+
@Serializable
48
+
classTarget
49
+
50
+
@Test
51
+
funtestJvmIntrinsics() {
52
+
val ser1 =Target.serializer()
53
+
assertFalse(SERIALIZERS_CACHE.isStored(Target::class), "Cache shouldn't have values before call to serializer<T>()")
54
+
val ser2 = serializer<Target>()
55
+
assertFalse(
56
+
SERIALIZERS_CACHE.isStored(Target::class),
57
+
"Serializer for Target::class is stored in the cache, which means that runtime lookup was performed and call to serializer<Target> was not intrinsified."+
58
+
"Check that compiler plugin intrinsics are enabled and working correctly."
59
+
)
60
+
val ser3 = serializer(typeOf<Target>())
61
+
assertTrue(SERIALIZERS_CACHE.isStored(Target::class), "Serializer should be stored in cache after typeOf-based lookup")
0 commit comments