[Test] Support some jvm codegen specific configuration directives
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND: JS
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=always-disable
|
||||
// ASSERTIONS_MODE: always-disable
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun checkTrue(): Boolean {
|
||||
@@ -42,4 +42,4 @@ fun box(): String {
|
||||
if (checkFalseWithMessage()) return "FAIL 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND: JS
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=always-enable
|
||||
// ASSERTIONS_MODE: always-enable
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun checkTrue(): Boolean {
|
||||
@@ -49,4 +49,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Assertions which run before the class initializer are always checked
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package classAssertions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package classAssertions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package classAssertions
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package classAssertions
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package classAssertions
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package interfaceAssertionsDisabled
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package interfaceAssertionsEnabled
|
||||
@@ -61,4 +61,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
// If assertions are disabled, neither argument to assert should be evaluated.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package localAnonymousFunction
|
||||
@@ -123,4 +123,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package localClass
|
||||
@@ -163,4 +163,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package localFunction
|
||||
@@ -123,4 +123,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package localLambda
|
||||
@@ -123,4 +123,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package localObject
|
||||
@@ -155,4 +155,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
// Reusing the $assertionsDisabled field in the Outer class might seem like a good idea,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package nonLocalReturn
|
||||
@@ -74,4 +74,4 @@ fun box(): String {
|
||||
if (!c.checkFalseWithMessage()) return "FAIL 8"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package ordinary
|
||||
@@ -99,4 +99,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
|
||||
package superClassInitializer
|
||||
@@ -117,4 +117,4 @@ fun box(): String {
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
package suspendFunctionAssertionDisabled
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
package suspendFunctionAssertionsEnabled
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
package suspendLambdaAssertionsDisabled
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm
|
||||
// ASSERTIONS_MODE: jvm
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
package suspendLambdaAssertionsEnabled
|
||||
|
||||
compiler/testData/codegen/box/constructorCall/inlineFunInConstructorCallWithDisabledNormalization.kt
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=disable
|
||||
// CONSTRUCTOR_CALL_NORMALIZATION_MODE: disable
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
Foo(
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable
|
||||
// CONSTRUCTOR_CALL_NORMALIZATION_MODE: enable
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
Foo(
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=preserve-class-initialization
|
||||
// CONSTRUCTOR_CALL_NORMALIZATION_MODE: preserve-class-initialization
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
Foo(
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable
|
||||
// CONSTRUCTOR_CALL_NORMALIZATION_MODE: enable
|
||||
open class A(val s: String)
|
||||
|
||||
inline fun test(crossinline z: () -> String): String {
|
||||
@@ -11,4 +11,4 @@ inline fun test(crossinline z: () -> String): String {
|
||||
|
||||
fun box(): String {
|
||||
return test { "OK" }
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable
|
||||
// CONSTRUCTOR_CALL_NORMALIZATION_MODE: enable
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
Foo(
|
||||
|
||||
+22
@@ -5,11 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.test.directives
|
||||
|
||||
import org.jetbrains.kotlin.config.JVMAssertionsMode
|
||||
import org.jetbrains.kotlin.config.JVMConstructorCallNormalizationMode
|
||||
import org.jetbrains.kotlin.config.JvmStringConcat
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
|
||||
object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
val JVM_TARGET by enumDirective<JvmTarget>(
|
||||
description = "Target bytecode version",
|
||||
additionalParser = JvmTarget.Companion::fromString
|
||||
@@ -34,4 +38,22 @@ object JvmEnvironmentConfigurationDirectives : SimpleDirectivesContainer() {
|
||||
val USE_PSI_CLASS_FILES_READING by directive("Use a slower (PSI-based) class files reading implementation")
|
||||
val USE_JAVAC by directive("Enable javac integration")
|
||||
val SKIP_JAVA_SOURCES by directive("Don't add java sources to compile classpath")
|
||||
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
val STRING_CONCAT by enumDirective<JvmStringConcat>(
|
||||
description = "Configure mode of string concatenation",
|
||||
additionalParser = JvmStringConcat.Companion::fromString
|
||||
)
|
||||
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
val ASSERTIONS_MODE by enumDirective<JVMAssertionsMode>(
|
||||
description = "Configure jvm assertions mode",
|
||||
additionalParser = JVMAssertionsMode.Companion::fromString
|
||||
)
|
||||
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
val CONSTRUCTOR_CALL_NORMALIZATION_MODE by enumDirective<JVMConstructorCallNormalizationMode>(
|
||||
description = "Configure jvm constructor call normalization mode",
|
||||
additionalParser = JVMConstructorCallNormalizationMode.Companion::fromStringOrNull
|
||||
)
|
||||
}
|
||||
|
||||
+10
@@ -19,6 +19,9 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.ASSERTIONS_MODE
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.CONSTRUCTOR_CALL_NORMALIZATION_MODE
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.STRING_CONCAT
|
||||
import org.jetbrains.kotlin.test.directives.LanguageSettingsDirectives
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
|
||||
@@ -26,6 +29,7 @@ import org.jetbrains.kotlin.test.model.DependencyDescription
|
||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.*
|
||||
import org.jetbrains.kotlin.test.services.DirectiveToConfigurationKeyExtractor
|
||||
import org.jetbrains.kotlin.test.services.jvm.CompiledClassesManager
|
||||
import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
@@ -44,6 +48,12 @@ class JvmEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfig
|
||||
override val additionalServices: List<ServiceRegistrationData>
|
||||
get() = listOf(service(::CompiledClassesManager))
|
||||
|
||||
override fun DirectiveToConfigurationKeyExtractor.provideConfigurationKeys() {
|
||||
register(STRING_CONCAT, JVMConfigurationKeys.STRING_CONCAT)
|
||||
register(ASSERTIONS_MODE, JVMConfigurationKeys.ASSERTIONS_MODE)
|
||||
register(CONSTRUCTOR_CALL_NORMALIZATION_MODE, JVMConfigurationKeys.CONSTRUCTOR_CALL_NORMALIZATION_MODE)
|
||||
}
|
||||
|
||||
override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule, project: MockProject) {
|
||||
if (module.targetPlatform !in JvmPlatforms.allJvmPlatforms) return
|
||||
val registeredDirectives = module.directives
|
||||
|
||||
Reference in New Issue
Block a user