mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
[Commonizer] Implement SingleTargetPropagationTest to cover KT-46248
^KT-46248
This commit is contained in:
committed by
Space
parent
965e328766
commit
7c1520a424
@@ -160,8 +160,8 @@ abstract class AbstractInlineSourcesCommonizationTest : KtInlineSourceCommonizer
|
||||
if (dependencies.isEmpty()) null
|
||||
else MockModulesProvider.create(dependencies)
|
||||
},
|
||||
targetProviders = TargetDependent(targets.map { it.target }) { commonizerTarget ->
|
||||
val target = targets.single { it.target == commonizerTarget }
|
||||
targetProviders = TargetDependent(outputTarget.allLeaves()) { commonizerTarget ->
|
||||
val target = targets.singleOrNull { it.target == commonizerTarget } ?: return@TargetDependent null
|
||||
TargetProvider(
|
||||
target = commonizerTarget,
|
||||
modulesProvider = MockModulesProvider.create(target.modules.map { createModuleDescriptor(it) })
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.commonizer.hierarchical
|
||||
|
||||
import org.jetbrains.kotlin.commonizer.AbstractInlineSourcesCommonizationTest
|
||||
import org.jetbrains.kotlin.commonizer.assertCommonized
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Related https://youtrack.jetbrains.com/issue/KT-46248
|
||||
*/
|
||||
class SingleTargetPropagationTest : AbstractInlineSourcesCommonizationTest() {
|
||||
|
||||
/**
|
||||
* Following the simple design principle:
|
||||
* Absent/Unsupported targets shall result in the same output as a request only mentioning supported targets
|
||||
*/
|
||||
@Test
|
||||
fun `test single native target in hierarchy`() {
|
||||
val result = commonize {
|
||||
outputTarget("((a, b), (c, d))")
|
||||
simpleSingleSourceTarget("a", """class A""")
|
||||
}
|
||||
|
||||
result.assertCommonized("a", "class A")
|
||||
result.assertCommonized("(a,b)", "expect class A expect constructor()")
|
||||
result.assertCommonized("((a, b), (c, d))", "expect class A expect constructor()")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user