web: fix and update compiler plugin test cases (#1452)

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
This commit is contained in:
Oleksandr Karpovich
2021-11-24 11:27:43 +01:00
committed by GitHub
parent af31eacb74
commit 84eb629cec
10 changed files with 51 additions and 32 deletions

View File

@@ -19,7 +19,3 @@ fun main() {
val router by Router
}
}
fun callComposable(content: @Composable () -> Unit) {
// does nothing
}

View File

@@ -2,6 +2,7 @@
// https://github.com/JetBrains/compose-jb/issues/1226
// TODO: move this to passing cases after kotlin 1.6.0
import kotlin.reflect.KProperty
import androidx.compose.runtime.Composable
@@ -21,7 +22,3 @@ fun main() {
)
}
}
fun callComposable(content: @Composable () -> Unit) {
// does nothing
}

View File

@@ -17,7 +17,3 @@ fun main() {
val router by Router()
}
}
fun callComposable(content: @Composable () -> Unit) {
// does nothing
}

View File

@@ -0,0 +1,14 @@
// @Module:Main
// https://github.com/JetBrains/compose-jb/issues/1436
import kotlin.reflect.KProperty
import androidx.compose.runtime.*
fun main() {
var (foo, setFoo) = mutableStateOf(0)
setFoo(123) // set
require(foo == 0) { "If this failed, it probably means the issue was fixed" }
require(foo == 123) { "Expected Failure (wrong behaviour)! foo was expected to get updated, but it's acutal value is $foo" }
}

View File

@@ -15,7 +15,7 @@ fun main() {
ComposableWithDifferentDefaultValuesForParameters(a = Any())
ComposableWithReturnAndWithDefaultLambda().invoke()
}
require(intArrayOf(1, 2, 3, 4, 5, 6, 7).all { it in set }) { "Failed when running composables - ${set.joinToString()}" }
require(setOf(1, 2, 3, 4, 5, 6, 7) == set) { "Failed when running composables - ${set.joinToString()}" }
}
// @Module:Lib

View File

@@ -20,7 +20,7 @@ fun main() {
}
}
require(intArrayOf(1, 2, 3, 4).all { it in set }) { "Failed when running composables" }
require(setOf(1, 2, 3, 4) == set) { "Failed when running composables" }
}

View File

@@ -1,16 +1,21 @@
// @Module:Main
// fixed in https://github.com/JetBrains/androidx/pull/118
import androidx.compose.runtime.Composable
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.Composer
fun main() {
callComposable {
ComposableWithTypedDefaultValue<String>({})
}
}
var called = false
fun callComposable(content: @Composable () -> Unit) {
val c = content
callComposable {
ComposableWithTypedDefaultValue<String>({ it ->
check(it.value == null)
called = true
})
}
require(called) { "Failed when running composables" }
}
// @Module:Lib
@@ -39,5 +44,7 @@ class NullWrapper<T> : NullableWrapper<T>() {
fun <T> ComposableWithTypedDefaultValue(
onChange: (NullableWrapper<T>) -> Unit,
valueWrapper: NullableWrapper<T> = NullWrapper()
) {}
) {
onChange(valueWrapper)
}

View File

@@ -16,7 +16,7 @@ fun main() {
instance2.composable()
set.add(2)
}
require(intArrayOf(1, 2).all { it in set }) { "Failed when running composables" }
require(setOf(1, 2) == set) { "Failed when running composables" }
}
// @Module:Lib

View File

@@ -1,30 +1,39 @@
// https://github.com/JetBrains/compose-jb/issues/774
// fixed in https://github.com/JetBrains/androidx/pull/118
import androidx.compose.runtime.Composable
val set = mutableSetOf<Int>()
fun main() {
callComposable {
Foo<String> { }
Foo<String> { set.add(1) }
Foo<String>()
FooTakesTypedComposableLambda2("T")
FooTakesTypedComposableLambda3("T")
}
}
fun callComposable(content: @Composable () -> Unit) {
// does nothing
require(setOf(1,2,3,4) == set) { "Failed when running composable. Actual result - ${set.joinToString()}" }
}
class RouterState<C>
@Composable
fun <C : Any> Foo(block: @Composable (RouterState<C>) -> Unit = {}) {}
fun <C : Any> Foo(block: @Composable (RouterState<C>) -> Unit = { set.add(2) }) {
block(RouterState())
}
@Composable
fun <T> FooTakesTypedComposableLambda2(t: T, composable: @Composable (T) -> T = { t }) {
fun <T> FooTakesTypedComposableLambda2(t: T, composable: @Composable (T) -> T = {
set.add(3)
t
}) {
composable(t)
}
@Composable
fun <T> FooTakesTypedComposableLambda3(t: T, composable: @Composable () -> T = { t }) {
fun <T> FooTakesTypedComposableLambda3(t: T, composable: @Composable () -> T = {
set.add(4)
t
}) {
composable()
}

View File

@@ -1,6 +1,6 @@
# __LATEST_COMPOSE_RELEASE_VERSION__
COMPOSE_CORE_VERSION=1.0.0-rc2
COMPOSE_WEB_VERSION=1.0.0-alpha4-build362
COMPOSE_CORE_VERSION=1.0.0-rc3
COMPOSE_WEB_VERSION=1.0.0-rc3
compose.web.buildSamples=false
compose.web.tests.integration.withFirefox
compose.web.tests.skip.benchmarks=false