Initial support for K2 compiler frontend (#92)
This commit is contained in:
+29
-1
@@ -1,3 +1,8 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jmailen.gradle.kotlinter.KotlinterPlugin
|
||||
import org.jmailen.gradle.kotlinter.tasks.FormatTask
|
||||
import org.jmailen.gradle.kotlinter.tasks.LintTask
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "1.8.20" apply false
|
||||
id("org.jetbrains.dokka") version "1.8.10" apply false
|
||||
@@ -11,8 +16,31 @@ allprojects {
|
||||
version = "0.13.0-SNAPSHOT"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
sourceCompatibility = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
plugins.withType<KotlinterPlugin> {
|
||||
val formatBuildscripts = tasks.register<FormatTask>("formatBuildscripts") {
|
||||
group = "verification"
|
||||
source(layout.projectDirectory.asFileTree.matching { include("**.kts") })
|
||||
}
|
||||
tasks.named("formatKotlin") { dependsOn(formatBuildscripts) }
|
||||
|
||||
val lintBuildscripts = tasks.register<LintTask>("lintBuildscripts") {
|
||||
group = "verification"
|
||||
source(layout.projectDirectory.asFileTree.matching { include("**.kts") })
|
||||
}
|
||||
tasks.named("lintKotlin") { dependsOn(lintBuildscripts) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jmailen.gradle.kotlinter.tasks.FormatTask
|
||||
import org.jmailen.gradle.kotlinter.tasks.LintTask
|
||||
|
||||
plugins {
|
||||
id("java-gradle-plugin")
|
||||
kotlin("jvm")
|
||||
@@ -36,14 +32,6 @@ gradlePlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.withType<JavaCompile> {
|
||||
sourceCompatibility = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
tasks.named("publish") {
|
||||
dependsOn("publishPlugins")
|
||||
@@ -57,14 +45,3 @@ publishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.register<FormatTask>("formatBuildscripts") {
|
||||
group = "verification"
|
||||
source(layout.projectDirectory.asFileTree.matching { include("**.kts") })
|
||||
}
|
||||
tasks.register<LintTask>("lintBuildscripts") {
|
||||
group = "verification"
|
||||
source(layout.projectDirectory.asFileTree.matching { include("**.kts") })
|
||||
}
|
||||
|
||||
tasks.named("lintKotlin") { dependsOn("lintBuildscripts") }
|
||||
tasks.named("formatKotlin") { dependsOn("formatBuildscripts") }
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jmailen.gradle.kotlinter.tasks.FormatTask
|
||||
import org.jmailen.gradle.kotlinter.tasks.LintTask
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
@@ -25,12 +23,9 @@ dependencies {
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
kotlinOptions.freeCompilerArgs = listOf("-opt-in=org.jetbrains.kotlin.backend.common.extensions.FirIncompatiblePluginAPI", "-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi")
|
||||
}
|
||||
tasks.withType<JavaCompile> {
|
||||
sourceCompatibility = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
kotlinOptions.freeCompilerArgs += listOf(
|
||||
"-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi",
|
||||
)
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
@@ -117,14 +112,3 @@ publishing {
|
||||
}
|
||||
}
|
||||
}
|
||||
tasks.register<FormatTask>("formatBuildscripts") {
|
||||
group = "verification"
|
||||
source(layout.projectDirectory.asFileTree.matching { include("**.kts") })
|
||||
}
|
||||
tasks.register<LintTask>("lintBuildscripts") {
|
||||
group = "verification"
|
||||
source(layout.projectDirectory.asFileTree.matching { include("**.kts") })
|
||||
}
|
||||
|
||||
tasks.named("lintKotlin") { dependsOn("lintBuildscripts") }
|
||||
tasks.named("formatKotlin") { dependsOn("formatBuildscripts") }
|
||||
|
||||
+21
-5
@@ -30,6 +30,7 @@ import com.bnorm.power.diagram.irDiagramString
|
||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.parentClassId
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
@@ -37,6 +38,7 @@ import org.jetbrains.kotlin.ir.backend.js.utils.asString
|
||||
import org.jetbrains.kotlin.ir.builders.irCall
|
||||
import org.jetbrains.kotlin.ir.builders.irString
|
||||
import org.jetbrains.kotlin.ir.builders.parent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||
@@ -57,11 +59,14 @@ import org.jetbrains.kotlin.ir.types.classifierOrNull
|
||||
import org.jetbrains.kotlin.ir.types.isBoolean
|
||||
import org.jetbrains.kotlin.ir.types.isSubtypeOf
|
||||
import org.jetbrains.kotlin.ir.types.isSubtypeOfClass
|
||||
import org.jetbrains.kotlin.ir.util.classId
|
||||
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
||||
import org.jetbrains.kotlin.ir.util.functions
|
||||
import org.jetbrains.kotlin.ir.util.isFileClass
|
||||
import org.jetbrains.kotlin.ir.util.isFunctionOrKFunction
|
||||
import org.jetbrains.kotlin.ir.util.kotlinFqName
|
||||
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
class PowerAssertCallTransformer(
|
||||
@@ -215,13 +220,13 @@ class PowerAssertCallTransformer(
|
||||
|
||||
// Java static functions require searching by class
|
||||
val parentClassFunctions = (
|
||||
function.parentClassOrNull
|
||||
?.let { context.referenceClass(it.kotlinFqName) }
|
||||
function.parentClassId
|
||||
?.let { context.referenceClass(it) }
|
||||
?.functions ?: emptySequence()
|
||||
)
|
||||
.filter { it.owner.kotlinFqName == function.kotlinFqName }
|
||||
.toList()
|
||||
val possible = (context.referenceFunctions(function.kotlinFqName) + parentClassFunctions)
|
||||
val possible = (context.referenceFunctions(function.callableId) + parentClassFunctions)
|
||||
.distinct()
|
||||
|
||||
return possible.mapNotNull { overload ->
|
||||
@@ -256,7 +261,7 @@ class PowerAssertCallTransformer(
|
||||
type.isFunctionOrKFunction() && type is IrSimpleType && (type.arguments.size == 1 && isStringSupertype(type.arguments.first()))
|
||||
|
||||
private fun isStringJavaSupplierFunction(type: IrType): Boolean {
|
||||
val javaSupplier = context.referenceClass(FqName("java.util.function.Supplier"))
|
||||
val javaSupplier = context.referenceClass(ClassId.topLevel(FqName("java.util.function.Supplier")))
|
||||
return javaSupplier != null && type.isSubtypeOfClass(javaSupplier) &&
|
||||
type is IrSimpleType && (type.arguments.size == 1 && isStringSupertype(type.arguments.first()))
|
||||
}
|
||||
@@ -289,3 +294,14 @@ class PowerAssertCallTransformer(
|
||||
report(severity, message, sourceFile.getCompilerMessageLocation(expression))
|
||||
}
|
||||
}
|
||||
|
||||
val IrFunction.callableId: CallableId
|
||||
get() {
|
||||
val parentClass = parent as? IrClass
|
||||
val classId = parentClass?.classId
|
||||
return if (classId != null && !parentClass.isFileClass) {
|
||||
CallableId(classId, name)
|
||||
} else {
|
||||
CallableId(parent.kotlinFqName, name)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-10
@@ -20,29 +20,27 @@ import com.google.auto.service.AutoService
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.com.intellij.mock.MockProject
|
||||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
||||
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
val KEY_FUNCTIONS = CompilerConfigurationKey<List<String>>("fully-qualified function names")
|
||||
|
||||
@AutoService(ComponentRegistrar::class)
|
||||
class PowerAssertComponentRegistrar(
|
||||
@AutoService(CompilerPluginRegistrar::class)
|
||||
class PowerAssertCompilerPluginRegistrar(
|
||||
private val functions: Set<FqName>,
|
||||
) : ComponentRegistrar {
|
||||
) : CompilerPluginRegistrar() {
|
||||
@Suppress("unused")
|
||||
constructor() : this(emptySet()) // Used by service loader
|
||||
|
||||
override fun registerProjectComponents(
|
||||
project: MockProject,
|
||||
configuration: CompilerConfiguration,
|
||||
) {
|
||||
override val supportsK2: Boolean = true
|
||||
|
||||
override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) {
|
||||
val functions = configuration[KEY_FUNCTIONS]?.map { FqName(it) } ?: functions
|
||||
if (functions.isEmpty()) return
|
||||
|
||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
||||
IrGenerationExtension.registerExtension(project, PowerAssertIrGenerationExtension(messageCollector, functions.toSet()))
|
||||
IrGenerationExtension.registerExtension(PowerAssertIrGenerationExtension(messageCollector, functions.toSet()))
|
||||
}
|
||||
}
|
||||
@@ -369,7 +369,7 @@ assertTrue(1 == 2, message = "${"$"}text, the world is broken")
|
||||
|
|
||||
false
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -386,7 +386,7 @@ require(1 == 2) { "the world is broken" }
|
||||
|
|
||||
false
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.require"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.require"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -403,7 +403,7 @@ check(1 == 2) { "the world is broken" }
|
||||
|
|
||||
false
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.check"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.check"))),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,24 +19,23 @@ package com.bnorm.power
|
||||
import com.tschuchort.compiletesting.KotlinCompilation
|
||||
import com.tschuchort.compiletesting.SourceFile
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
||||
import org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import java.io.OutputStream
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.fail
|
||||
|
||||
private val DEFAULT_COMPONENT_REGISTRARS = arrayOf(
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert"))),
|
||||
private val DEFAULT_COMPILER_PLUGIN_REGISTRARS = arrayOf(
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.assert"))),
|
||||
)
|
||||
|
||||
fun compile(
|
||||
list: List<SourceFile>,
|
||||
vararg componentRegistrars: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS,
|
||||
vararg compilerPluginRegistrars: CompilerPluginRegistrar = DEFAULT_COMPILER_PLUGIN_REGISTRARS,
|
||||
): KotlinCompilation.Result {
|
||||
return KotlinCompilation().apply {
|
||||
sources = list
|
||||
useIR = true
|
||||
messageOutputStream = object : OutputStream() {
|
||||
override fun write(b: Int) {
|
||||
// black hole all writes
|
||||
@@ -46,18 +45,18 @@ fun compile(
|
||||
// black hole all writes
|
||||
}
|
||||
}
|
||||
this.componentRegistrars = componentRegistrars.toList()
|
||||
this.compilerPluginRegistrars = compilerPluginRegistrars.toList()
|
||||
inheritClassPath = true
|
||||
}.compile()
|
||||
}
|
||||
|
||||
fun executeAssertion(
|
||||
@Language("kotlin") source: String,
|
||||
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS,
|
||||
vararg compilerPluginRegistrars: CompilerPluginRegistrar = DEFAULT_COMPILER_PLUGIN_REGISTRARS,
|
||||
): String {
|
||||
val result = compile(
|
||||
listOf(SourceFile.kotlin("main.kt", source, trimIndent = false)),
|
||||
*plugins,
|
||||
*compilerPluginRegistrars,
|
||||
)
|
||||
assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode, result.messages)
|
||||
|
||||
@@ -86,8 +85,8 @@ fun main() {
|
||||
fun assertMessage(
|
||||
@Language("kotlin") source: String,
|
||||
message: String,
|
||||
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS,
|
||||
vararg compilerPluginRegistrars: CompilerPluginRegistrar = DEFAULT_COMPILER_PLUGIN_REGISTRARS,
|
||||
) {
|
||||
val actual = executeAssertion(source, *plugins)
|
||||
val actual = executeAssertion(source, *compilerPluginRegistrars)
|
||||
assertEquals(message, actual)
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ fun main() {
|
||||
trimIndent = false,
|
||||
)
|
||||
|
||||
val result = compile(listOf(file), PowerAssertComponentRegistrar(setOf(FqName("dbg"))))
|
||||
val result = compile(listOf(file), PowerAssertCompilerPluginRegistrar(setOf(FqName("dbg"))))
|
||||
assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode)
|
||||
|
||||
val kClazz = result.classLoader.loadClass("MainKt")
|
||||
|
||||
@@ -350,7 +350,7 @@ class InfixFunctionTest {
|
||||
}
|
||||
|
||||
private fun run(file: SourceFile, fqNames: Set<FqName>, main: String = "MainKt"): String {
|
||||
val result = compile(listOf(file), PowerAssertComponentRegistrar(fqNames))
|
||||
val result = compile(listOf(file), PowerAssertCompilerPluginRegistrar(fqNames))
|
||||
assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode, "Failed with messages: " + result.messages)
|
||||
|
||||
val kClazz = result.classLoader.loadClass(main)
|
||||
|
||||
+15
-15
@@ -35,7 +35,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
false ==> expected: <true> but was: <false>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
false ==> expected: <true> but was: <false>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
false ==> expected: <true> but was: <false>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
false ==> expected: <true> but was: <false>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
false ==> expected: <true> but was: <false>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
true ==> expected: <false> but was: <true>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
true ==> expected: <false> but was: <true>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
true ==> expected: <false> but was: <true>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
true ==> expected: <false> but was: <true>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ class Junit5AssertionsTest {
|
||||
|
|
||||
true ==> expected: <false> but was: <true>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ class Junit5AssertionsTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ class Junit5AssertionsTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ class Junit5AssertionsTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ class Junit5AssertionsTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ class Junit5AssertionsTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -35,7 +35,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
false
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
false
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
false
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
true
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
true
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
true
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class KotlinTestAssertTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class KotlinTestAssertTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class KotlinTestAssertTest {
|
||||
| World
|
||||
Hello ==> expected: <Hello> but was: <World>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
null ==> expected: not <null>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
null ==> expected: not <null>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ class KotlinTestAssertTest {
|
||||
|
|
||||
null ==> expected: not <null>
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class LamdaTest {
|
||||
false
|
||||
)
|
||||
""".trimIndent(),
|
||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.require"))),
|
||||
PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.require"))),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@ fun main() {
|
||||
trimIndent = false,
|
||||
)
|
||||
|
||||
val result = compile(listOf(file), PowerAssertComponentRegistrar(setOf(FqName("dbg"))))
|
||||
val result = compile(listOf(file), PowerAssertCompilerPluginRegistrar(setOf(FqName("dbg"))))
|
||||
assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode)
|
||||
|
||||
val kClazz = result.classLoader.loadClass("MainKt")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") version "1.7.0"
|
||||
kotlin("multiplatform") version "1.8.20"
|
||||
id("com.bnorm.power.kotlin-power-assert") version "0.12.1"
|
||||
}
|
||||
|
||||
@@ -51,6 +51,13 @@ kotlin {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Kotlin/JS loses class information at the IR level -> Soft-assertion doesn't work
|
||||
// targets.all {
|
||||
// compilations.all {
|
||||
// kotlinOptions.languageVersion = "2.0"
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
tasks.withType<Test> {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user