Minor. Patch test to avoid failing in Native

This commit is contained in:
Mikhael Bogdanov
2019-01-18 09:52:56 +01:00
parent a4386cf28a
commit 8fb2633bf4
+8 -8
View File
@@ -1,18 +1,18 @@
// FILE: 1.kt // FILE: 1.kt
package test package test
class C { class C<T>(val value: T) {
var inserting: Boolean = false var inserting: Boolean = false
fun nextSlot(): Any? = null fun nextSlot(): Any? = null
fun startNode(key: Any?) {} fun startNode(key: Any?) {}
fun endNode() {} fun endNode() {}
fun emitNode(node: Any?) {} fun emitNode(node: Any?) {}
fun useNode(): Any? = null fun useNode(): T = value
fun skipValue() {} fun skipValue() {}
fun updateValue(value: Any?) {} fun updateValue(value: Any?) {}
} }
class B<T>(val composer: C, val node: T) { class B<T>(val composer: C<T>, val node: T) {
inline fun <V> bar(value: V, block: T.(V) -> Unit) = with(composer) { inline fun <V> bar(value: V, block: T.(V) -> Unit) = with(composer) {
if (inserting || nextSlot() != value) { if (inserting || nextSlot() != value) {
updateValue(value) updateValue(value)
@@ -21,13 +21,13 @@ class B<T>(val composer: C, val node: T) {
} }
} }
class A(val composer: C) { class A<T>(val composer: C<T>) {
inline fun <T> foo(key: Any, ctor: () -> T, update: B<T>.() -> Unit) = with(composer) { inline fun foo(key: Any, ctor: () -> T, update: B<T>.() -> Unit) = with(composer) {
startNode(key) startNode(key)
val node = if (inserting) val node = if (inserting)
ctor().also { emitNode(it) } ctor().also { emitNode(it) }
else useNode() as T else useNode() as T
B<T>(this, node).update() B(this, node).update()
endNode() endNode()
} }
} }
@@ -36,10 +36,10 @@ class A(val composer: C) {
import test.* import test.*
fun box(): String { fun box(): String {
val a = A(C()) val a = A(C("foo"))
val str = "OK" val str = "OK"
var result = "fail" var result = "fail"
a.foo<String>( a.foo(
123, 123,
{ "abc" }, { "abc" },
{ {