Drop deprecated Delegates.lazy and blockingLazy and ObservableProperty constructor-like function

This commit is contained in:
Ilya Gorbunov
2015-10-31 04:45:34 +03:00
parent 219e69be22
commit 70fdc379ef
2 changed files with 12 additions and 163 deletions
@@ -91,79 +91,9 @@ class UnsafeNullableLazyValTest {
}
}
class UnsafeLazyValDeprecatedTest {
var result = 0
val a by Delegates.lazy {
++result
}
@test fun doTest() {
a
assertTrue(a == 1, "fail: initializer should be invoked only once")
}
}
class BlockingLazyValDeprecatedTest {
var result = 0
val a by Delegates.blockingLazy {
++result
}
@test fun doTest() {
a
assertTrue(a == 1, "fail: initializer should be invoked only once")
}
}
class UnsafeNullableLazyValDeprecatedTest {
var resultA = 0
var resultB = 0
val a: Int? by Delegates.lazy { resultA++; null}
val b by Delegates.lazy { foo() }
@test fun doTest() {
a
b
assertTrue(a == null, "fail: a should be null")
assertTrue(b == null, "fail: b should be null")
assertTrue(resultA == 1, "fail: initializer for a should be invoked only once")
assertTrue(resultB == 1, "fail: initializer for b should be invoked only once")
}
fun foo(): String? {
resultB++
return null
}
}
class BlockingNullableLazyValDeprecatedTest {
var resultA = 0
var resultB = 0
val a: Int? by Delegates.blockingLazy { resultA++; null}
val b by Delegates.blockingLazy { foo() }
@test fun doTest() {
a
b
assertTrue(a == null, "fail: a should be null")
assertTrue(b == null, "fail: a should be null")
assertTrue(resultA == 1, "fail: initializer for a should be invoked only once")
assertTrue(resultB == 1, "fail: initializer for b should be invoked only once")
}
fun foo(): String? {
resultB++
return null
}
}
class IdentityEqualsIsUsedToUnescapeLazyValTest {
var equalsCalled = 0
val a by lazy { ClassWithCustomEquality { equalsCalled++ } }
private val a by lazy { ClassWithCustomEquality { equalsCalled++ } }
@test fun doTest() {
a