[PowerAssert] Add codegen tests
This commit is contained in:
@@ -5,6 +5,8 @@ plugins {
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
val junit5Classpath by configurations.creating
|
||||
|
||||
dependencies {
|
||||
embedded(project(":kotlin-power-assert-compiler-plugin.backend")) { isTransitive = false }
|
||||
embedded(project(":kotlin-power-assert-compiler-plugin.cli")) { isTransitive = false }
|
||||
@@ -18,6 +20,8 @@ dependencies {
|
||||
|
||||
testRuntimeOnly(commonDependency("org.codehaus.woodstox:stax2-api"))
|
||||
testRuntimeOnly(commonDependency("com.fasterxml:aalto-xml"))
|
||||
|
||||
junit5Classpath(libs.junit.jupiter.api)
|
||||
}
|
||||
|
||||
optInToExperimentalCompilerApi()
|
||||
@@ -41,4 +45,10 @@ projectTest(parallel = true) {
|
||||
dependsOn(":dist")
|
||||
workingDir = rootDir
|
||||
useJUnitPlatform()
|
||||
|
||||
val localJunit5Classpath: FileCollection = junit5Classpath
|
||||
|
||||
doFirst {
|
||||
systemProperty("junit5.classpath", localJunit5Classpath.files.joinToString(",") { it.absolutePath })
|
||||
}
|
||||
}
|
||||
|
||||
+20
-1
@@ -30,7 +30,26 @@ import java.io.File
|
||||
data class SourceFile(
|
||||
private val irFile: IrFile,
|
||||
) {
|
||||
private val source: String = File(irFile.path).readText()
|
||||
companion object {
|
||||
private val KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS = System.getProperty("KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS") ?: ""
|
||||
private val sourceRoots = listOf(".") + KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS.split(",").map { it.trim() }
|
||||
}
|
||||
|
||||
private val source: String = run {
|
||||
File(irFile.path).also { file ->
|
||||
if (file.exists()) {
|
||||
return@run file.readText()
|
||||
}
|
||||
}
|
||||
|
||||
for (root in sourceRoots) {
|
||||
val file = File(root, irFile.path)
|
||||
if (file.exists()) {
|
||||
return@run file.readText()
|
||||
}
|
||||
}
|
||||
throw IllegalArgumentException("Unable to find source for IrFile: ${irFile.path}")
|
||||
}
|
||||
.replace("\r\n", "\n") // https://youtrack.jetbrains.com/issue/KT-41888
|
||||
|
||||
fun getSourceRangeInfo(element: IrElement): SourceRangeInfo {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.powerassert
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.config.addJvmClasspathRoot
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.RuntimeClasspathProvider
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import java.io.File
|
||||
|
||||
private val junit5Classpath = System.getProperty("junit5.classpath").split(",")
|
||||
|
||||
fun TestConfigurationBuilder.enableJunit() {
|
||||
useConfigurators(::JunitEnvironmentConfigurator)
|
||||
useCustomRuntimeClasspathProviders(::JunitRuntimeClassPathProvider)
|
||||
}
|
||||
|
||||
class JunitEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
|
||||
override fun configureCompilerConfiguration(configuration: CompilerConfiguration, module: TestModule) {
|
||||
if (PowerAssertConfigurationDirectives.WITH_JUNIT5 in module.directives) {
|
||||
for (file in junit5Classpath.map { File(it) }) {
|
||||
configuration.addJvmClasspathRoot(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class JunitRuntimeClassPathProvider(testServices: TestServices) : RuntimeClasspathProvider(testServices) {
|
||||
override fun runtimeClassPaths(module: TestModule): List<File> {
|
||||
if (PowerAssertConfigurationDirectives.WITH_JUNIT5 in module.directives) {
|
||||
return junit5Classpath.map { File(it) }
|
||||
} else {
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.powerassert
|
||||
|
||||
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
|
||||
|
||||
object PowerAssertConfigurationDirectives : SimpleDirectivesContainer() {
|
||||
val FUNCTION by stringDirective(
|
||||
description = "Functions targeted by Power-Assert transformation",
|
||||
multiLine = true,
|
||||
)
|
||||
|
||||
val WITH_JUNIT5 by directive("Add JUnit5 to classpath")
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.powerassert
|
||||
|
||||
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.compiler.plugin.CompilerPluginRegistrar
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives
|
||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives.WITH_STDLIB
|
||||
import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.FULL_JDK
|
||||
import org.jetbrains.kotlin.test.directives.model.DirectivesContainer
|
||||
import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives
|
||||
import org.jetbrains.kotlin.test.model.TestFile
|
||||
import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.runners.codegen.AbstractFirLightTreeBlackBoxCodegenTest
|
||||
import org.jetbrains.kotlin.test.runners.codegen.AbstractIrBlackBoxCodegenTest
|
||||
import org.jetbrains.kotlin.test.services.AdditionalSourceProvider
|
||||
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import java.io.File
|
||||
|
||||
// ------------------------ codegen ------------------------
|
||||
|
||||
open class AbstractIrBlackBoxCodegenTestForPowerAssert : AbstractIrBlackBoxCodegenTest() {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.configurePlugin()
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractFirLightTreeBlackBoxCodegenTestForPowerAssert : AbstractFirLightTreeBlackBoxCodegenTest() {
|
||||
override fun configure(builder: TestConfigurationBuilder) {
|
||||
super.configure(builder)
|
||||
builder.configurePlugin()
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------ configuration ------------------------
|
||||
|
||||
fun TestConfigurationBuilder.configurePlugin() {
|
||||
// TODO there has got to be a better way?
|
||||
val sourceRoots = File("plugins/power-assert/testData/")
|
||||
.walkTopDown()
|
||||
.filter { it.isDirectory }
|
||||
.joinToString(",") { it.path }
|
||||
System.setProperty("KOTLIN_POWER_ASSERT_ADD_SRC_ROOTS", sourceRoots)
|
||||
|
||||
|
||||
defaultDirectives {
|
||||
+FULL_JDK
|
||||
+WITH_STDLIB
|
||||
}
|
||||
useDirectives(PowerAssertConfigurationDirectives)
|
||||
|
||||
useConfigurators(::PowerAssertEnvironmentConfigurator)
|
||||
|
||||
useAdditionalSourceProviders(
|
||||
::AdditionalSourceFilesProvider,
|
||||
)
|
||||
|
||||
enableJunit()
|
||||
}
|
||||
|
||||
class PowerAssertEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
|
||||
override fun CompilerPluginRegistrar.ExtensionStorage.registerCompilerExtensions(
|
||||
module: TestModule,
|
||||
configuration: CompilerConfiguration,
|
||||
) {
|
||||
val functions = moduleStructure.allDirectives[PowerAssertConfigurationDirectives.FUNCTION]
|
||||
.ifEmpty { listOf("kotlin.assert") }
|
||||
.mapTo(mutableSetOf()) { FqName(it) }
|
||||
|
||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
||||
IrGenerationExtension.registerExtension(PowerAssertIrGenerationExtension(messageCollector, functions))
|
||||
}
|
||||
}
|
||||
|
||||
class AdditionalSourceFilesProvider(testServices: TestServices) : AdditionalSourceProvider(testServices) {
|
||||
override val directiveContainers: List<DirectivesContainer> =
|
||||
listOf(AdditionalFilesDirectives)
|
||||
|
||||
override fun produceAdditionalFiles(globalDirectives: RegisteredDirectives, module: TestModule): List<TestFile> {
|
||||
return buildList {
|
||||
add(File("plugins/power-assert/testData/helpers/InfixDispatch.kt").toTestFile())
|
||||
add(File("plugins/power-assert/testData/helpers/InfixExtension.kt").toTestFile())
|
||||
add(File("plugins/power-assert/testData/helpers/utils.kt").toTestFile())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
the world is broken
|
||||
check(1 == 2) { "the world is broken" }
|
||||
|
|
||||
false
|
||||
@@ -0,0 +1,5 @@
|
||||
// FUNCTION: kotlin.check
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
check(1 == 2) { "the world is broken" }
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Assertion failed
|
||||
@@ -0,0 +1,5 @@
|
||||
// FUNCTION: kotlin.require
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(false)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Not equal
|
||||
assert(1 == 2, lambda)
|
||||
|
|
||||
false
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val lambda = { "Not equal" }
|
||||
assert(1 == 2, lambda)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Not equal
|
||||
assert(1 == 2) { "Not equal" }
|
||||
|
|
||||
false
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(1 == 2) { "Not equal" }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Assertion failed
|
||||
assert(hello.length == "World".substring(1, 4).length)
|
||||
| | | | |
|
||||
| | | | 3
|
||||
| | | orl
|
||||
| | false
|
||||
| 5
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val hello = "Hello"
|
||||
assert(hello.length == "World".substring(1, 4).length)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
Assertion failed
|
||||
assert(
|
||||
text
|
||||
|
|
||||
Hello
|
||||
== null ||
|
||||
|
|
||||
false
|
||||
(
|
||||
text.length == 5 &&
|
||||
| | |
|
||||
| | true
|
||||
| 5
|
||||
Hello
|
||||
text.toLowerCase() == text
|
||||
| | | |
|
||||
| | | Hello
|
||||
| | false
|
||||
| hello
|
||||
Hello
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text: String? = "Hello"
|
||||
assert(
|
||||
text
|
||||
== null ||
|
||||
(
|
||||
text.length == 5 &&
|
||||
text.toLowerCase() == text
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
the world is broken
|
||||
require(1 == 2) { "the world is broken" }
|
||||
|
|
||||
false
|
||||
@@ -0,0 +1,5 @@
|
||||
// FUNCTION: kotlin.require
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
require(1 == 2) { "the world is broken" }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
Assertion failed
|
||||
assert(hello.reversed() == emptyList<String>())
|
||||
| | | |
|
||||
| | | []
|
||||
| | false
|
||||
| [World, Hello]
|
||||
[Hello, World]
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val hello = listOf("Hello", "World")
|
||||
assert(hello.reversed() == emptyList<String>())
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(1 + 1 == 4)
|
||||
| |
|
||||
| false
|
||||
2
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(1 + 1 == 4)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(2 / 1 == 4)
|
||||
| |
|
||||
| false
|
||||
2
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(2 / 1 == 4)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(1 * 2 == 4)
|
||||
| |
|
||||
| false
|
||||
2
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(1 * 2 == 4)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(i-- == 4)
|
||||
| |
|
||||
| false
|
||||
3
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
var i = 3
|
||||
assert(i-- == 4)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(i++ == 4)
|
||||
| |
|
||||
| false
|
||||
1
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
var i = 1
|
||||
assert(i++ == 4)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(--i == 4)
|
||||
| |
|
||||
| false
|
||||
2
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
var i = 3
|
||||
assert(--i == 4)
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(++i == 4)
|
||||
| |
|
||||
| false
|
||||
2
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
var i = 1
|
||||
assert(++i == 4)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(3 - 1 == 4)
|
||||
| |
|
||||
| false
|
||||
2
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(3 - 1 == 4)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
Assertion failed
|
||||
assert(text != null && text.length == 5 && text.toLowerCase() == text)
|
||||
| | | | | | | | |
|
||||
| | | | | | | | Hello
|
||||
| | | | | | | false
|
||||
| | | | | | hello
|
||||
| | | | | Hello
|
||||
| | | | true
|
||||
| | | 5
|
||||
| | Hello
|
||||
| true
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text: String? = "Hello"
|
||||
assert(text != null && text.length == 5 && text.toLowerCase() == text)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
Assertion failed
|
||||
assert(text != null && (text.length == 1 || text.toLowerCase() == text))
|
||||
| | | | | | | | |
|
||||
| | | | | | | | Hello
|
||||
| | | | | | | false
|
||||
| | | | | | hello
|
||||
| | | | | Hello
|
||||
| | | | false
|
||||
| | | 5
|
||||
| | Hello
|
||||
| true
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text: String? = "Hello"
|
||||
assert(text != null && (text.length == 1 || text.toLowerCase() == text))
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
Assertion failed
|
||||
assert((text.length == 1 || text.toLowerCase() == text) && text.length == 1)
|
||||
| | | | | | |
|
||||
| | | | | | Hello
|
||||
| | | | | false
|
||||
| | | | hello
|
||||
| | | Hello
|
||||
| | false
|
||||
| 5
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text = "Hello"
|
||||
assert((text.length == 1 || text.toLowerCase() == text) && text.length == 1)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
Assertion failed
|
||||
assert(text == null || (text.length == 5 && text.toLowerCase() == text))
|
||||
| | | | | | | | |
|
||||
| | | | | | | | Hello
|
||||
| | | | | | | false
|
||||
| | | | | | hello
|
||||
| | | | | Hello
|
||||
| | | | true
|
||||
| | | 5
|
||||
| | Hello
|
||||
| false
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text: String? = "Hello"
|
||||
assert(text == null || (text.length == 5 && text.toLowerCase() == text))
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
Assertion failed
|
||||
assert((text.length == 5 && text.toLowerCase() == text) || text.length == 1)
|
||||
| | | | | | | | | |
|
||||
| | | | | | | | | false
|
||||
| | | | | | | | 5
|
||||
| | | | | | | Hello
|
||||
| | | | | | Hello
|
||||
| | | | | false
|
||||
| | | | hello
|
||||
| | | Hello
|
||||
| | true
|
||||
| 5
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text = "Hello"
|
||||
assert((text.length == 5 && text.toLowerCase() == text) || text.length == 1)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
Assertion failed
|
||||
assert(text == null || text.length == 1 || text.toLowerCase() == text)
|
||||
| | | | | | | | |
|
||||
| | | | | | | | Hello
|
||||
| | | | | | | false
|
||||
| | | | | | hello
|
||||
| | | | | Hello
|
||||
| | | | false
|
||||
| | | 5
|
||||
| | Hello
|
||||
| false
|
||||
Hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text: String? = "Hello"
|
||||
assert(text == null || text.length == 1 || text.toLowerCase() == text)
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Assertion failed
|
||||
assert(text != null && text.length == 1)
|
||||
| |
|
||||
| false
|
||||
null
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val text: String? = null
|
||||
assert(text != null && text.length == 1)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Assertion failed
|
||||
assert(null is String)
|
||||
|
|
||||
false
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert(null is String)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
Assertion failed
|
||||
assert("Hello, world!" !is String)
|
||||
|
|
||||
false
|
||||
@@ -0,0 +1,3 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
assert("Hello, world!" !is String)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Assertion failed
|
||||
assert(greeting is String && greeting.length == 2)
|
||||
| | | | |
|
||||
| | | | false
|
||||
| | | 5
|
||||
| | hello
|
||||
| true
|
||||
hello
|
||||
@@ -0,0 +1,4 @@
|
||||
fun box() = expectThrowableMessage {
|
||||
val greeting: Any = "hello"
|
||||
assert(greeting is String && greeting.length == 2)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
sum=6
|
||||
dbg(operation, 1 + 2 + 3)
|
||||
| | |
|
||||
| | 6
|
||||
| 3
|
||||
sum
|
||||
@@ -0,0 +1,9 @@
|
||||
// FUNCTION: dbg
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
val operation = "sum"
|
||||
dbg(operation, 1 + 2 + 3)
|
||||
}
|
||||
|
||||
fun <T> dbg(key: Any, value: T): T = value
|
||||
fun <T> dbg(key: Any, value: T, msg: String): T = throw RuntimeException(key.toString() + "=" + value + "\n" + msg)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
false=true
|
||||
dbg(
|
||||
key = greeting != null && greeting.length == 5,
|
||||
| |
|
||||
| false
|
||||
null
|
||||
value = name == null || name.length == 5
|
||||
| |
|
||||
| true
|
||||
null
|
||||
)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// FUNCTION: dbg
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
val greeting: String? = null
|
||||
val name: String? = null
|
||||
dbg(
|
||||
key = greeting != null && greeting.length == 5,
|
||||
value = name == null || name.length == 5
|
||||
)
|
||||
}
|
||||
|
||||
fun <T> dbg(key: Any, value: T): T = value
|
||||
fun <T> dbg(key: Any, value: T, msg: String): T = throw RuntimeException(key.toString() + "=" + value + "\n" + msg)
|
||||
@@ -0,0 +1,7 @@
|
||||
sum=6
|
||||
Message:
|
||||
dbg(operation, 1 + 2 + 3, "Message:")
|
||||
| | |
|
||||
| | 6
|
||||
| 3
|
||||
sum
|
||||
@@ -0,0 +1,9 @@
|
||||
// FUNCTION: dbg
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
val operation = "sum"
|
||||
dbg(operation, 1 + 2 + 3, "Message:")
|
||||
}
|
||||
|
||||
fun <T> dbg(key: Any, value: T): T = value
|
||||
fun <T> dbg(key: Any, value: T, msg: String): T = throw RuntimeException(key.toString() + "=" + value + "\n" + msg)
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
false=true
|
||||
Message:
|
||||
dbg(
|
||||
key = greeting != null && greeting.length == 5,
|
||||
| |
|
||||
| false
|
||||
null
|
||||
value = name == null || name.length == 5,
|
||||
| |
|
||||
| true
|
||||
null
|
||||
msg = "Message:"
|
||||
)
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// FUNCTION: dbg
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
val greeting: String? = null
|
||||
val name: String? = null
|
||||
dbg(
|
||||
key = greeting != null && greeting.length == 5,
|
||||
value = name == null || name.length == 5,
|
||||
msg = "Message:"
|
||||
)
|
||||
}
|
||||
|
||||
fun <T> dbg(key: Any, value: T): T = value
|
||||
fun <T> dbg(key: Any, value: T, msg: String): T = throw RuntimeException(key.toString() + "=" + value + "\n" + msg)
|
||||
@@ -0,0 +1,4 @@
|
||||
dbg(1 + 2 + 3)
|
||||
| |
|
||||
| 6
|
||||
3
|
||||
@@ -0,0 +1,8 @@
|
||||
// FUNCTION: dbg
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
dbg(1 + 2 + 3)
|
||||
}
|
||||
|
||||
fun <T> dbg(value: T): T = value
|
||||
fun <T> dbg(value: T, msg: String): T = throw RuntimeException(msg)
|
||||
@@ -0,0 +1,5 @@
|
||||
Message:
|
||||
dbg(1 + 2 + 3, "Message:")
|
||||
| |
|
||||
| 6
|
||||
3
|
||||
@@ -0,0 +1,8 @@
|
||||
// FUNCTION: dbg
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
dbg(1 + 2 + 3, "Message:")
|
||||
}
|
||||
|
||||
fun <T> dbg(value: T): T = value
|
||||
fun <T> dbg(value: T, msg: String): T = throw RuntimeException(msg)
|
||||
@@ -0,0 +1,5 @@
|
||||
Wrapper(1 + 1) mustEqual (2 + 4)
|
||||
| | |
|
||||
| | 6
|
||||
| 2
|
||||
Wrapper
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(1 + 1) mustEqual (2 + 4)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Wrapper(1 + 1) mustEqual 6
|
||||
| |
|
||||
| 2
|
||||
Wrapper
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(1 + 1) mustEqual 6
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Wrapper(1) mustEqual (2 + 4)
|
||||
| |
|
||||
| 6
|
||||
Wrapper
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(1) mustEqual (2 + 4)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Wrapper(2) mustEqual 6
|
||||
|
|
||||
Wrapper
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(2) mustEqual 6
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
Wrapper(1 + 1).mustEqual(2 + 4)
|
||||
| | |
|
||||
| | 6
|
||||
| 2
|
||||
Wrapper
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(1 + 1).mustEqual(2 + 4)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Wrapper(1 + 1).mustEqual(6)
|
||||
| |
|
||||
| 2
|
||||
Wrapper
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(1 + 1).mustEqual(6)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
Wrapper(1).mustEqual(2 + 4)
|
||||
| |
|
||||
| 6
|
||||
Wrapper
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(1).mustEqual(2 + 4)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
Wrapper(2).mustEqual(6)
|
||||
|
|
||||
Wrapper
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.dispatch.Wrapper.mustEqual
|
||||
|
||||
import infix.dispatch.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
Wrapper(2).mustEqual(6)
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
(1 + 1) mustEqual (2 + 4)
|
||||
| |
|
||||
| 6
|
||||
2
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
(1 + 1) mustEqual (2 + 4)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
(1 + 1) mustEqual 6
|
||||
|
|
||||
2
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
(1 + 1) mustEqual 6
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
1 mustEqual (2 + 4)
|
||||
|
|
||||
6
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
1 mustEqual (2 + 4)
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Assertion failed
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
2 mustEqual 6
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
(1 + 1).mustEqual(2 + 4)
|
||||
| |
|
||||
| 6
|
||||
2
|
||||
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
(1 + 1).mustEqual(2 + 4)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
(1 + 1).mustEqual(6)
|
||||
|
|
||||
2
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
(1 + 1).mustEqual(6)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
1.mustEqual(2 + 4)
|
||||
|
|
||||
6
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// FUNCTION: infix.extension.mustEqual
|
||||
|
||||
import infix.extension.*
|
||||
|
||||
fun box() = expectThrowableMessage {
|
||||
1.mustEqual(2 + 4)
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Assertion failed
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user