Lazy: Rename valueCreated property to isInitialized() function.
Notes about behavior of Lazy when initializer throws an exception.
This commit is contained in:
@@ -11,10 +11,10 @@ class LazyJVMTest {
|
||||
test fun lazyInitializationForcedOnSerialization() {
|
||||
for(mode in listOf(LazyThreadSafetyMode.SYNCHRONIZED, LazyThreadSafetyMode.NONE)) {
|
||||
val lazy = lazy(mode) { "initialized" }
|
||||
assertFalse(lazy.valueCreated)
|
||||
assertFalse(lazy.isInitialized())
|
||||
val lazy2 = serializeAndDeserialize(lazy)
|
||||
assertTrue(lazy.valueCreated)
|
||||
assertTrue(lazy2.valueCreated)
|
||||
assertTrue(lazy.isInitialized())
|
||||
assertTrue(lazy2.isInitialized())
|
||||
assertEquals(lazy.value, lazy2.value)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ class LazyTest {
|
||||
var callCount = 0
|
||||
val lazyInt = lazy { ++callCount }
|
||||
|
||||
assertFalse(lazyInt.valueCreated)
|
||||
assertFalse(lazyInt.isInitialized())
|
||||
assertEquals(0, callCount)
|
||||
|
||||
lazyInt.value
|
||||
|
||||
assertTrue(lazyInt.valueCreated)
|
||||
assertTrue(lazyInt.isInitialized())
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user