Browse Source

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

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
pull/1455/head
Oleksandr Karpovich 3 years ago committed by GitHub
parent
commit
84eb629cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      web/compose-compiler-integration/testcases/failing/CompanionGetValueOperatorComposable.kt
  2. 5
      web/compose-compiler-integration/testcases/failing/ComposableWithNullableTypeParameter.kt
  3. 4
      web/compose-compiler-integration/testcases/failing/InstanceGetValueOperatorComposable.kt
  4. 14
      web/compose-compiler-integration/testcases/failing/MutableStateDestructuringDeclarartion.kt
  5. 2
      web/compose-compiler-integration/testcases/passing/ComposableWithParamsWithDefaultValues.kt
  6. 2
      web/compose-compiler-integration/testcases/passing/ComposableWithTypeParams.kt
  7. 17
      web/compose-compiler-integration/testcases/passing/ComposableWithTypedDefaultValues.kt
  8. 2
      web/compose-compiler-integration/testcases/passing/PassingComposableToConstructor.kt
  9. 25
      web/compose-compiler-integration/testcases/passing/WithComposableBlockUsingTypeParameterAndDefaultValue.kt
  10. 4
      web/gradle.properties

4
web/compose-compiler-integration/testcases/failing/CompanionGetValueOperatorComposable.kt

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

5
web/compose-compiler-integration/testcases/failing/ComposableWithNullableTypeParameter.kt

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

4
web/compose-compiler-integration/testcases/failing/InstanceGetValueOperatorComposable.kt

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

14
web/compose-compiler-integration/testcases/failing/MutableStateDestructuringDeclarartion.kt

@ -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" }
}

2
web/compose-compiler-integration/testcases/passing/ComposableWithParamsWithDefaultValues.kt

@ -15,7 +15,7 @@ fun main() {
ComposableWithDifferentDefaultValuesForParameters(a = Any()) ComposableWithDifferentDefaultValuesForParameters(a = Any())
ComposableWithReturnAndWithDefaultLambda().invoke() 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 // @Module:Lib

2
web/compose-compiler-integration/testcases/passing/ComposableWithTypeParams.kt

@ -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" }
} }

17
web/compose-compiler-integration/testcases/failing/ComposableWithTypedDefaultValues.kt → web/compose-compiler-integration/testcases/passing/ComposableWithTypedDefaultValues.kt

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

2
web/compose-compiler-integration/testcases/passing/PassingComposableToConstructor.kt

@ -16,7 +16,7 @@ fun main() {
instance2.composable() instance2.composable()
set.add(2) 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 // @Module:Lib

25
web/compose-compiler-integration/testcases/failing/WithComposableBlockUsingTypeParameterAndDefaultValue.kt → web/compose-compiler-integration/testcases/passing/WithComposableBlockUsingTypeParameterAndDefaultValue.kt

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

4
web/gradle.properties

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

Loading…
Cancel
Save