bump kotlinter to 3.14 and ktlint action to 1.5.1 (#86)

* add kotlinter 3.14

* force trailing commas

* bump ktlint action to 1.5.1

* run ./gradlew formatKotlin

* disable kotlinter plugin because it triggers a problem in the kotlin compiler
This commit is contained in:
Christoph Sturm
2023-04-07 14:42:43 +02:00
committed by GitHub
parent 36fe1734bd
commit 87b209ab91
31 changed files with 284 additions and 269 deletions
+2
View File
@@ -14,3 +14,5 @@ ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_allow_trailing_comma = true
+1 -1
View File
@@ -47,7 +47,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Run ktlint
uses: ScaCap/action-ktlint@1.4
uses: ScaCap/action-ktlint@1.5.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
+1
View File
@@ -3,6 +3,7 @@ plugins {
id("org.jetbrains.dokka") version "1.7.0" apply false
id("com.gradle.plugin-publish") version "1.1.0" apply false
id("com.github.gmazzo.buildconfig") version "3.1.0" apply false
// id("org.jmailen.kotlinter") version "3.14.0" apply false
}
allprojects {
@@ -5,6 +5,7 @@ plugins {
kotlin("jvm")
id("com.gradle.plugin-publish")
id("com.github.gmazzo.buildconfig")
// id("org.jmailen.kotlinter")
}
dependencies {
@@ -39,11 +39,11 @@ class PowerAssertGradlePlugin : KotlinCompilerPluginSupportPlugin {
override fun getPluginArtifact(): SubpluginArtifact = SubpluginArtifact(
groupId = BuildConfig.PLUGIN_GROUP_ID,
artifactId = BuildConfig.PLUGIN_ARTIFACT_ID,
version = BuildConfig.PLUGIN_VERSION
version = BuildConfig.PLUGIN_VERSION,
)
override fun applyToCompilation(
kotlinCompilation: KotlinCompilation<*>
kotlinCompilation: KotlinCompilation<*>,
): Provider<List<SubpluginOption>> {
val project = kotlinCompilation.target.project
val extension = project.extensions.getByType(PowerAssertGradleExtension::class.java)
@@ -7,6 +7,7 @@ plugins {
signing
`maven-publish`
// id("org.jmailen.kotlinter")
}
dependencies {
@@ -68,7 +68,7 @@ class PowerAssertCallTransformer(
private val sourceFile: SourceFile,
private val context: IrPluginContext,
private val messageCollector: MessageCollector,
private val functions: Set<FqName>
private val functions: Set<FqName>,
) : IrElementTransformerVoidWithContext() {
private val irTypeSystemContext = IrTypeSystemContextImpl(context.irBuiltIns)
@@ -95,7 +95,7 @@ class PowerAssertCallTransformer(
| - $fqName($valueTypesTruncated() -> String)
| - $fqName(${valueTypesAll}String)
| - $fqName($valueTypesAll() -> String)
""".trimMargin()
""".trimMargin(),
)
return super.visitCall(expression)
}
@@ -132,7 +132,7 @@ class PowerAssertCallTransformer(
messageArgument = messageArgument,
roots = roots,
dispatchRoot = dispatchRoot,
extensionRoot = extensionRoot
extensionRoot = extensionRoot,
)
}
@@ -142,14 +142,14 @@ class PowerAssertCallTransformer(
messageArgument: IrExpression?,
roots: List<Node?>,
dispatchRoot: Node? = null,
extensionRoot: Node? = null
extensionRoot: Node? = null,
): IrExpression {
fun recursive(
index: Int,
dispatch: IrExpression?,
extension: IrExpression?,
arguments: List<IrExpression?>,
variables: List<IrTemporaryVariable>
variables: List<IrTemporaryVariable>,
): IrExpression {
if (index >= roots.size) {
val prefix = buildMessagePrefix(messageArgument, delegate.messageParameter, roots, call)
@@ -181,7 +181,7 @@ class PowerAssertCallTransformer(
messageArgument: IrExpression?,
messageParameter: IrValueParameter,
roots: List<Node?>,
original: IrCall
original: IrCall,
): IrExpression? {
return when {
messageArgument is IrConst<*> -> messageArgument
@@ -32,14 +32,14 @@ class PowerAssertCommandLineProcessor : CommandLineProcessor {
valueDescription = "function full-qualified name",
description = "fully qualified path of function to intercept",
required = false, // TODO required for Kotlin/JS
allowMultipleOccurrences = true
)
allowMultipleOccurrences = true,
),
)
override fun processOption(
option: AbstractCliOption,
value: String,
configuration: CompilerConfiguration
configuration: CompilerConfiguration,
) {
return when (option.optionName) {
"function" -> configuration.add(KEY_FUNCTIONS, value)
@@ -30,13 +30,14 @@ val KEY_FUNCTIONS = CompilerConfigurationKey<List<String>>("fully-qualified func
@AutoService(ComponentRegistrar::class)
class PowerAssertComponentRegistrar(
private val functions: Set<FqName>
private val functions: Set<FqName>,
) : ComponentRegistrar {
@Suppress("unused") constructor() : this(emptySet()) // Used by service loader
@Suppress("unused")
constructor() : this(emptySet()) // Used by service loader
override fun registerProjectComponents(
project: MockProject,
configuration: CompilerConfiguration
configuration: CompilerConfiguration,
) {
val functions = configuration[KEY_FUNCTIONS]?.map { FqName(it) } ?: functions
if (functions.isEmpty()) return
@@ -45,5 +46,3 @@ class PowerAssertComponentRegistrar(
IrGenerationExtension.registerExtension(project, PowerAssertIrGenerationExtension(messageCollector, functions.toSet()))
}
}
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.name.FqName
class PowerAssertIrGenerationExtension(
private val messageCollector: MessageCollector,
private val functions: Set<FqName>
private val functions: Set<FqName>,
) : IrGenerationExtension {
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) {
for (file in moduleFragment.files) {
@@ -36,7 +36,7 @@ interface FunctionDelegate {
dispatchReceiver: IrExpression?,
extensionReceiver: IrExpression?,
valueArguments: List<IrExpression?>,
messageArgument: IrExpression
messageArgument: IrExpression,
): IrExpression
fun IrBuilderWithScope.irCallCopy(
@@ -45,7 +45,7 @@ interface FunctionDelegate {
dispatchReceiver: IrExpression?,
extensionReceiver: IrExpression?,
valueArguments: List<IrExpression?>,
messageArgument: IrExpression
messageArgument: IrExpression,
): IrExpression {
return irCall(overload, type = original.type).apply {
this.dispatchReceiver = original.dispatchReceiver?.deepCopyWithSymbols(parent)
@@ -36,7 +36,7 @@ class LambdaFunctionDelegate(
dispatchReceiver: IrExpression?,
extensionReceiver: IrExpression?,
valueArguments: List<IrExpression?>,
messageArgument: IrExpression
messageArgument: IrExpression,
): IrExpression = with(builder) {
val expression = irLambda(context.irBuiltIns.stringType, messageParameter.type) {
+irReturn(messageArgument)
@@ -47,7 +47,7 @@ class LambdaFunctionDelegate(
dispatchReceiver = dispatchReceiver,
extensionReceiver = extensionReceiver,
valueArguments = valueArguments,
messageArgument = expression
messageArgument = expression,
)
}
}
@@ -37,7 +37,7 @@ class SamConversionLambdaFunctionDelegate(
dispatchReceiver: IrExpression?,
extensionReceiver: IrExpression?,
valueArguments: List<IrExpression?>,
messageArgument: IrExpression
messageArgument: IrExpression,
): IrExpression = with(builder) {
val lambda = irLambda(context.irBuiltIns.stringType, messageParameter.type) {
+irReturn(messageArgument)
@@ -49,7 +49,7 @@ class SamConversionLambdaFunctionDelegate(
dispatchReceiver = dispatchReceiver,
extensionReceiver = extensionReceiver,
valueArguments = valueArguments,
messageArgument = expression
messageArgument = expression,
)
}
}
@@ -34,13 +34,13 @@ class SimpleFunctionDelegate(
dispatchReceiver: IrExpression?,
extensionReceiver: IrExpression?,
valueArguments: List<IrExpression?>,
messageArgument: IrExpression
messageArgument: IrExpression,
): IrExpression = builder.irCallCopy(
overload = overload,
original = original,
dispatchReceiver = dispatchReceiver,
extensionReceiver = extensionReceiver,
valueArguments = valueArguments,
messageArgument = messageArgument
messageArgument = messageArgument,
)
}
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
fun IrBuilderWithScope.buildDiagramNesting(
root: Node,
variables: List<IrTemporaryVariable> = emptyList(),
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression,
): IrExpression {
return buildExpression(root, variables) { argument, subStack ->
call(argument, subStack)
@@ -37,7 +37,7 @@ fun IrBuilderWithScope.buildDiagramNesting(
fun IrBuilderWithScope.buildDiagramNestingNullable(
root: Node?,
variables: List<IrTemporaryVariable> = emptyList(),
call: IrBuilderWithScope.(IrExpression?, List<IrTemporaryVariable>) -> IrExpression
call: IrBuilderWithScope.(IrExpression?, List<IrTemporaryVariable>) -> IrExpression,
): IrExpression {
return if (root != null) buildDiagramNesting(root, variables, call) else call(null, variables)
}
@@ -45,7 +45,7 @@ fun IrBuilderWithScope.buildDiagramNestingNullable(
private fun IrBuilderWithScope.buildExpression(
node: Node,
variables: List<IrTemporaryVariable>,
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression,
): IrExpression = when (node) {
is ExpressionNode -> add(node, variables, call)
is AndNode -> nest(node, 0, variables, call)
@@ -69,7 +69,7 @@ private fun IrBuilderWithScope.buildExpression(
private fun IrBuilderWithScope.add(
node: ExpressionNode,
variables: List<IrTemporaryVariable>,
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression,
): IrExpression {
return irBlock {
val head = node.expressions.first().deepCopyWithSymbols(scope.getLocalDeclarationParent())
@@ -100,18 +100,21 @@ private fun IrBuilderWithScope.nest(
node: AndNode,
index: Int,
variables: List<IrTemporaryVariable>,
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression,
): IrExpression {
val children = node.children
val child = children[index]
return buildExpression(child, variables) { argument, newVariables ->
if (index + 1 == children.size) call(argument, newVariables) // last expression, result is false
else irIfThenElse(
context.irBuiltIns.anyType,
argument,
nest(node, index + 1, newVariables, call), // more expressions, continue nesting
call(irFalse(), newVariables), // short-circuit result to false
)
if (index + 1 == children.size) {
call(argument, newVariables) // last expression, result is false
} else {
irIfThenElse(
context.irBuiltIns.anyType,
argument,
nest(node, index + 1, newVariables, call), // more expressions, continue nesting
call(irFalse(), newVariables), // short-circuit result to false
)
}
}
}
@@ -135,17 +138,20 @@ private fun IrBuilderWithScope.nest(
node: OrNode,
index: Int,
variables: List<IrTemporaryVariable>,
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression
call: IrBuilderWithScope.(IrExpression, List<IrTemporaryVariable>) -> IrExpression,
): IrExpression {
val children = node.children
val child = children[index]
return buildExpression(child, variables) { argument, newVariables ->
if (index + 1 == children.size) call(argument, newVariables) // last expression, result is false
else irIfThenElse(
context.irBuiltIns.anyType,
argument,
call(irTrue(), newVariables), // short-circuit result to true
nest(node, index + 1, newVariables, call), // more expressions, continue nesting
)
if (index + 1 == children.size) {
call(argument, newVariables) // last expression, result is false
} else {
irIfThenElse(
context.irBuiltIns.anyType,
argument,
call(irTrue(), newVariables), // short-circuit result to true
nest(node, index + 1, newVariables, call), // more expressions, continue nesting
)
}
}
}
@@ -75,113 +75,116 @@ fun buildTree(expression: IrExpression): Node? {
}
val tree = RootNode()
expression.accept(object : IrElementVisitor<Unit, Node> {
override fun visitElement(element: IrElement, data: Node) {
element.acceptChildren(this, data)
}
expression.accept(
object : IrElementVisitor<Unit, Node> {
override fun visitElement(element: IrElement, data: Node) {
element.acceptChildren(this, data)
}
override fun visitExpression(expression: IrExpression, data: Node) {
if (expression is IrFunctionExpression) return // Do not transform lambda expressions, especially their body
override fun visitExpression(expression: IrExpression, data: Node) {
if (expression is IrFunctionExpression) return // Do not transform lambda expressions, especially their body
val node = data as? ExpressionNode ?: ExpressionNode().also { data.addChild(it) }
node.add(expression)
expression.acceptChildren(this, node)
}
override fun visitContainerExpression(expression: IrContainerExpression, data: Node) {
if (expression.origin is IrStatementOrigin.SAFE_CALL) {
// Null safe expressions can be correctly navigated
super.visitContainerExpression(expression, data)
} else {
// Everything else is considered unsafe and terminates the expression tree
val node = data as? ExpressionNode ?: ExpressionNode().also { data.addChild(it) }
node.add(expression)
}
}
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: Node) {
val node = data as? ExpressionNode ?: ExpressionNode().also { data.addChild(it) }
if (expression.operator in setOf(IrTypeOperator.INSTANCEOF, IrTypeOperator.NOT_INSTANCEOF)) {
// Only include `is` and `!is` checks
node.add(expression)
expression.acceptChildren(this, node)
}
expression.acceptChildren(this, node)
}
override fun visitContainerExpression(expression: IrContainerExpression, data: Node) {
if (expression.origin is IrStatementOrigin.SAFE_CALL) {
// Null safe expressions can be correctly navigated
super.visitContainerExpression(expression, data)
} else {
// Everything else is considered unsafe and terminates the expression tree
val node = data as? ExpressionNode ?: ExpressionNode().also { data.addChild(it) }
node.add(expression)
}
}
override fun visitCall(expression: IrCall, data: Node) {
if (expression.symbol.owner.name.asString() == "EQEQ" && expression.origin == IrStatementOrigin.EXCLEQ) {
// Skip the EQEQ part of a EXCLEQ call
override fun visitTypeOperator(expression: IrTypeOperatorCall, data: Node) {
val node = data as? ExpressionNode ?: ExpressionNode().also { data.addChild(it) }
if (expression.operator in setOf(IrTypeOperator.INSTANCEOF, IrTypeOperator.NOT_INSTANCEOF)) {
// Only include `is` and `!is` checks
node.add(expression)
}
expression.acceptChildren(this, node)
}
override fun visitCall(expression: IrCall, data: Node) {
if (expression.symbol.owner.name.asString() == "EQEQ" && expression.origin == IrStatementOrigin.EXCLEQ) {
// Skip the EQEQ part of a EXCLEQ call
expression.acceptChildren(this, data)
} else {
super.visitCall(expression, data)
}
}
override fun visitVararg(expression: IrVararg, data: Node) {
// Skip processing of vararg array
expression.acceptChildren(this, data)
} else {
super.visitCall(expression, data)
}
}
override fun visitVararg(expression: IrVararg, data: Node) {
// Skip processing of vararg array
expression.acceptChildren(this, data)
}
override fun visitConst(expression: IrConst<*>, data: Node) {
// Do not include constants
}
override fun visitConst(expression: IrConst<*>, data: Node) {
// Do not include constants
}
override fun visitWhen(expression: IrWhen, data: Node) {
when (expression.origin) {
IrStatementOrigin.ANDAND -> {
// flatten `&&` expressions to be at the same level
val node = data as? AndNode ?: AndNode().also { data.addChild(it) }
override fun visitWhen(expression: IrWhen, data: Node) {
when (expression.origin) {
IrStatementOrigin.ANDAND -> {
// flatten `&&` expressions to be at the same level
val node = data as? AndNode ?: AndNode().also { data.addChild(it) }
require(expression.branches.size == 2)
val thenBranch = expression.branches[0]
require(expression.branches.size == 2)
val thenBranch = expression.branches[0]
thenBranch.condition.accept(this, node)
thenBranch.result.accept(this, node)
thenBranch.condition.accept(this, node)
thenBranch.result.accept(this, node)
val elseBranchCondition = expression.branches[1].condition
val elseBranchResult = expression.branches[1].result
val elseBranchCondition = expression.branches[1].condition
val elseBranchResult = expression.branches[1].result
if (elseBranchCondition !is IrConst<*> || elseBranchCondition.value != true) {
elseBranchCondition.accept(this, node)
}
if (elseBranchCondition !is IrConst<*> || elseBranchCondition.value != true) {
elseBranchCondition.accept(this, node)
if (elseBranchResult !is IrConst<*> || elseBranchResult.value != false) {
elseBranchResult.accept(this, node)
}
}
IrStatementOrigin.OROR -> {
// flatten `||` expressions to be at the same level
val node = data as? OrNode ?: OrNode().also { data.addChild(it) }
if (elseBranchResult !is IrConst<*> || elseBranchResult.value != false) {
elseBranchResult.accept(this, node)
require(expression.branches.size == 2)
val thenBranchCondition = expression.branches[0].condition
val thenBranchResult = expression.branches[0].result
val elseBranchCondition = expression.branches[1].condition
val elseBranchResult = expression.branches[1].result
thenBranchCondition.accept(this, node)
if (thenBranchResult !is IrConst<*> || thenBranchResult.value != true) {
thenBranchResult.accept(this, node)
}
if (elseBranchCondition !is IrConst<*> || elseBranchCondition.value != true) {
elseBranchCondition.accept(this, node)
}
if (elseBranchResult !is IrConst<*> || elseBranchResult.value != false) {
elseBranchResult.accept(this, node)
}
}
}
IrStatementOrigin.OROR -> {
// flatten `||` expressions to be at the same level
val node = data as? OrNode ?: OrNode().also { data.addChild(it) }
require(expression.branches.size == 2)
val thenBranchCondition = expression.branches[0].condition
val thenBranchResult = expression.branches[0].result
val elseBranchCondition = expression.branches[1].condition
val elseBranchResult = expression.branches[1].result
thenBranchCondition.accept(this, node)
if (thenBranchResult !is IrConst<*> || thenBranchResult.value != true) {
thenBranchResult.accept(this, node)
else -> {
// Add as basic expression and terminate
// TODO this has to be broken and not work in all cases...
ExpressionNode().also { data.addChild(it) }
}
if (elseBranchCondition !is IrConst<*> || elseBranchCondition.value != true) {
elseBranchCondition.accept(this, node)
}
if (elseBranchResult !is IrConst<*> || elseBranchResult.value != false) {
elseBranchResult.accept(this, node)
}
}
else -> {
// Add as basic expression and terminate
// TODO this has to be broken and not work in all cases...
ExpressionNode().also { data.addChild(it) }
}
}
}
}, tree)
},
tree,
)
return tree.children.singleOrNull()
}
@@ -38,7 +38,7 @@ fun IrBuilderWithScope.irDiagramString(
sourceFile: SourceFile,
prefix: IrExpression? = null,
call: IrCall,
variables: List<IrTemporaryVariable>
variables: List<IrTemporaryVariable>,
): IrExpression {
val callInfo = sourceFile.getSourceRangeInfo(call)
val callIndent = callInfo.startColumnNumber
@@ -69,7 +69,7 @@ fun IrBuilderWithScope.irDiagramString(
last = i
}
}
}
},
)
for (tmp in rowValues.asReversed()) {
@@ -83,7 +83,7 @@ fun IrBuilderWithScope.irDiagramString(
last = i
}
indent(tmp.indent - last - 1)
}
},
)
addArgument(irGet(tmp.value))
}
@@ -95,13 +95,13 @@ private data class ValueDisplay(
val value: IrVariable,
val indent: Int,
val row: Int,
val source: String
val source: String,
)
private fun IrTemporaryVariable.toValueDisplay(
fileSource: SourceFile,
callIndent: Int,
originalInfo: SourceRangeInfo
originalInfo: SourceRangeInfo,
): ValueDisplay {
val info = fileSource.getSourceRangeInfo(original)
var indent = info.startColumnNumber - callIndent
@@ -158,7 +158,7 @@ private fun IrTemporaryVariable.toValueDisplay(
private fun findDisplayOffset(
sourceFile: SourceFile,
expression: IrExpression,
source: String
source: String,
): Int {
return when (expression) {
is IrMemberAccessExpression<*> -> memberAccessOffset(sourceFile, expression, source)
@@ -170,7 +170,7 @@ private fun findDisplayOffset(
private fun memberAccessOffset(
sourceFile: SourceFile,
expression: IrMemberAccessExpression<*>,
source: String
source: String,
): Int {
if (expression.origin == IrStatementOrigin.EXCLEQ || expression.origin == IrStatementOrigin.EXCLEQEQ) {
// special case to handle `value != null`
@@ -207,7 +207,7 @@ private fun memberAccessOffset(
private fun typeOperatorOffset(
expression: IrTypeOperatorCall,
source: String
source: String,
): Int {
return when (expression.operator) {
IrTypeOperator.INSTANCEOF -> source.indexOf(" is ") + 1
@@ -26,12 +26,12 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
data class IrTemporaryVariable(
val temporary: IrVariable,
val original: IrExpression
val original: IrExpression,
)
class IrTemporaryExtractionTransformer(
private val builder: IrStatementsBuilder<*>,
private val transform: Set<IrExpression>
private val transform: Set<IrExpression>,
) : IrElementTransformerVoid() {
private val _variables = mutableListOf<IrTemporaryVariable>()
val variables: List<IrTemporaryVariable> = _variables
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.ir.expressions.IrCall
import java.io.File
data class SourceFile(
private val irFile: IrFile
private val irFile: IrFile,
) {
private val source: String = File(irFile.path).readText()
.replace("\r\n", "\n") // https://youtrack.jetbrains.com/issue/KT-41888
@@ -39,7 +39,7 @@ fun IrBuilderWithScope.irLambda(
lambdaType: IrType,
startOffset: Int = this.startOffset,
endOffset: Int = this.endOffset,
block: IrBlockBodyBuilder.() -> Unit
block: IrBlockBodyBuilder.() -> Unit,
): IrFunctionExpression {
val scope = this
val lambda = context.irFactory.buildFun {
@@ -31,7 +31,7 @@ class ArithmeticExpressionTest {
| false
2
""".trimIndent(),
actual
actual,
)
}
@@ -46,7 +46,7 @@ class ArithmeticExpressionTest {
| false
2
""".trimIndent(),
actual
actual,
)
}
@@ -61,7 +61,7 @@ class ArithmeticExpressionTest {
| false
2
""".trimIndent(),
actual
actual,
)
}
@@ -76,7 +76,7 @@ class ArithmeticExpressionTest {
| false
2
""".trimIndent(),
actual
actual,
)
}
@@ -86,7 +86,7 @@ class ArithmeticExpressionTest {
"""
var i = 1
assert(++i == 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -96,7 +96,7 @@ class ArithmeticExpressionTest {
| false
2
""".trimIndent(),
actual
actual,
)
}
@@ -106,7 +106,7 @@ class ArithmeticExpressionTest {
"""
var i = 1
assert(i++ == 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -116,7 +116,7 @@ class ArithmeticExpressionTest {
| false
1
""".trimIndent(),
actual
actual,
)
}
@@ -126,7 +126,7 @@ class ArithmeticExpressionTest {
"""
var i = 3
assert(--i == 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -136,7 +136,7 @@ class ArithmeticExpressionTest {
| false
2
""".trimIndent(),
actual
actual,
)
}
@@ -146,7 +146,7 @@ class ArithmeticExpressionTest {
"""
var i = 3
assert(i-- == 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -156,7 +156,7 @@ class ArithmeticExpressionTest {
| false
3
""".trimIndent(),
actual
actual,
)
}
}
@@ -37,7 +37,7 @@ assert(hello.length == "World".substring(1, 4).length)
| | false
| 5
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -57,7 +57,7 @@ assert(hello.reversed() == emptyList<String>())
| | false
| [World, Hello]
[Hello, World]
""".trimIndent()
""".trimIndent(),
)
}
@@ -73,7 +73,7 @@ Not equal
assert(1 == 2) { "Not equal" }
|
false
""".trimIndent()
""".trimIndent(),
)
}
@@ -90,7 +90,7 @@ fun main() {
assert(1 == 2, lambda)
|
false
""".trimIndent()
""".trimIndent(),
)
}
@@ -108,7 +108,7 @@ assert(text != null && text.length == 1)
| |
| false
null
""".trimIndent()
""".trimIndent(),
)
}
@@ -133,7 +133,7 @@ assert(text != null && text.length == 5 && text.toLowerCase() == text)
| | Hello
| true
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -158,7 +158,7 @@ assert(text == null || text.length == 1 || text.toLowerCase() == text)
| | Hello
| false
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -183,7 +183,7 @@ assert(text != null && (text.length == 1 || text.toLowerCase() == text))
| | Hello
| true
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -206,7 +206,7 @@ assert((text.length == 1 || text.toLowerCase() == text) && text.length == 1)
| | false
| 5
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -231,7 +231,7 @@ assert(text == null || (text.length == 5 && text.toLowerCase() == text))
| | Hello
| false
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -257,7 +257,7 @@ assert((text.length == 5 && text.toLowerCase() == text) || text.length == 1)
| | true
| 5
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -277,7 +277,7 @@ assert(text?.length?.minus(2) == 1)
| | 3
| 5
Hello
""".trimIndent()
""".trimIndent(),
)
}
@@ -294,7 +294,7 @@ fun main() {
| |
| false
2
""".trimIndent()
""".trimIndent(),
)
assertMessage(
@@ -308,7 +308,7 @@ assert(1 shl 1 == 4)
| |
| false
2
""".trimIndent()
""".trimIndent(),
)
}
@@ -349,7 +349,7 @@ assert(
Hello
)
)
""".trimIndent()
""".trimIndent(),
)
}
@@ -368,8 +368,8 @@ Hello, the world is broken
assertTrue(1 == 2, message = "${"$"}text, the world is broken")
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
)
}
@@ -385,8 +385,8 @@ the world is broken
require(1 == 2) { "the world is broken" }
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.require")))
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.require"))),
)
}
@@ -402,8 +402,8 @@ the world is broken
check(1 == 2) { "the world is broken" }
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.check")))
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.check"))),
)
}
@@ -421,7 +421,8 @@ assert(a == 42)
| |
| false
0
""".trimIndent())
""".trimIndent(),
)
}
@Test
@@ -434,7 +435,7 @@ fun main() {
}""",
"""
Assertion failed
""".trimIndent()
""".trimIndent(),
)
}
}
@@ -30,7 +30,7 @@ class CastExpressionTest {
|
false
""".trimIndent(),
actual
actual,
)
}
@@ -44,7 +44,7 @@ class CastExpressionTest {
|
false
""".trimIndent(),
actual
actual,
)
}
@@ -54,7 +54,7 @@ class CastExpressionTest {
"""
val greeting: Any = "hello"
assert(greeting is String && greeting.length == 2)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -67,7 +67,7 @@ class CastExpressionTest {
| true
hello
""".trimIndent(),
actual
actual,
)
}
}
@@ -31,7 +31,7 @@ class DebugFunctionTest {
val actual = executeMainDebug(
"""
dbg(1 + 2 + 3)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -40,7 +40,7 @@ class DebugFunctionTest {
| 6
3
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -49,7 +49,7 @@ class DebugFunctionTest {
val actual = executeMainDebug(
"""
dbg(1 + 2 + 3, "Message:")
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -59,7 +59,7 @@ class DebugFunctionTest {
| 6
3
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
}
@@ -79,7 +79,7 @@ fun main() {
$mainBody
}
""",
trimIndent = false
trimIndent = false,
)
val result = compile(listOf(file), PowerAssertComponentRegistrar(setOf(FqName("dbg"))))
@@ -96,8 +96,9 @@ fun getMainResult(main: Method): String {
fail("main did not throw expected exception")
} catch (t: InvocationTargetException) {
with(t.cause) {
if (this is RuntimeException && message != null && message!!.startsWith("result:"))
if (this is RuntimeException && message != null && message!!.startsWith("result:")) {
return message!!.substringAfter("result:")
}
}
throw t.cause!!
}
@@ -30,7 +30,7 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
(1 + 1) mustEqual (2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -39,7 +39,7 @@ class InfixFunctionTest {
| 6
2
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -48,7 +48,7 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
1 mustEqual (2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -56,7 +56,7 @@ class InfixFunctionTest {
|
6
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -65,7 +65,7 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
(1 + 1) mustEqual 6
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -73,7 +73,7 @@ class InfixFunctionTest {
|
2
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -82,13 +82,13 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
2 mustEqual 6
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
Assertion failed
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -97,7 +97,7 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
(1 + 1).mustEqual(2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -106,7 +106,7 @@ class InfixFunctionTest {
| 6
2
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -115,7 +115,7 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
1.mustEqual(2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -123,7 +123,7 @@ class InfixFunctionTest {
|
6
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -132,7 +132,7 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
(1 + 1).mustEqual(6)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -140,7 +140,7 @@ class InfixFunctionTest {
|
2
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -149,13 +149,13 @@ class InfixFunctionTest {
val actual = runExtensionInfix(
"""
2.mustEqual(6)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
Assertion failed
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -164,7 +164,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(1 + 1) mustEqual (2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -174,7 +174,7 @@ class InfixFunctionTest {
| 2
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -183,7 +183,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(1) mustEqual (2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -192,7 +192,7 @@ class InfixFunctionTest {
| 6
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -201,7 +201,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(1 + 1) mustEqual 6
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -210,7 +210,7 @@ class InfixFunctionTest {
| 2
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -219,7 +219,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(2) mustEqual 6
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -227,7 +227,7 @@ class InfixFunctionTest {
|
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -236,7 +236,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(1 + 1).mustEqual(2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -246,7 +246,7 @@ class InfixFunctionTest {
| 2
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -255,7 +255,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(1).mustEqual(2 + 4)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -264,7 +264,7 @@ class InfixFunctionTest {
| 6
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -273,7 +273,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(1 + 1).mustEqual(6)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -282,7 +282,7 @@ class InfixFunctionTest {
| 2
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -291,7 +291,7 @@ class InfixFunctionTest {
val actual = runDispatchInfix(
"""
Wrapper(2).mustEqual(6)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -299,7 +299,7 @@ class InfixFunctionTest {
|
Wrapper
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -317,9 +317,9 @@ class InfixFunctionTest {
$mainBody
}
""".trimIndent(),
trimIndent = false
trimIndent = false,
),
setOf(FqName("mustEqual"))
setOf(FqName("mustEqual")),
)
}
@@ -343,9 +343,9 @@ class InfixFunctionTest {
$mainBody
}
""".trimIndent(),
trimIndent = false
trimIndent = false,
),
setOf(FqName("Wrapper.mustEqual"))
setOf(FqName("Wrapper.mustEqual")),
)
}
@@ -35,7 +35,7 @@ class Junit5AssertionsTest {
|
false ==> expected: <true> but was: <false>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertTrue")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(setOf(FqName("org.junit.jupiter.api.Assertions.assertEquals"))),
)
}
}
@@ -35,7 +35,7 @@ class KotlinTestAssertTest {
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
)
}
@@ -54,7 +54,7 @@ class KotlinTestAssertTest {
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
)
}
@@ -74,7 +74,7 @@ class KotlinTestAssertTest {
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue"))),
)
}
@@ -93,7 +93,7 @@ class KotlinTestAssertTest {
|
true
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
)
}
@@ -112,7 +112,7 @@ class KotlinTestAssertTest {
|
true
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse"))),
)
}
@@ -132,7 +132,7 @@ class KotlinTestAssertTest {
|
true
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(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")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertEquals"))),
)
}
@@ -217,7 +217,7 @@ class KotlinTestAssertTest {
|
null ==> expected: not <null>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
)
}
@@ -237,7 +237,7 @@ class KotlinTestAssertTest {
|
null ==> expected: not <null>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
)
}
@@ -258,7 +258,7 @@ class KotlinTestAssertTest {
|
null ==> expected: not <null>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull"))),
)
}
}
@@ -35,7 +35,7 @@ class LamdaTest {
| | false
| [Doe, Jane, Doe, John]
[Jane, John]
""".trimIndent()
""".trimIndent(),
)
}
@@ -65,7 +65,7 @@ class LamdaTest {
false
)
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.require")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.require"))),
)
}
}
@@ -29,7 +29,7 @@ class MultiParameterFunctionTest {
"""
val operation = "sum"
dbg(operation, 1 + 2 + 3)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -40,7 +40,7 @@ class MultiParameterFunctionTest {
| 3
sum
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -54,7 +54,7 @@ class MultiParameterFunctionTest {
key = greeting != null && greeting.length == 5,
value = name == null || name.length == 5
)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -70,7 +70,7 @@ class MultiParameterFunctionTest {
null
)
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -80,7 +80,7 @@ class MultiParameterFunctionTest {
"""
val operation = "sum"
dbg(operation, 1 + 2 + 3, "Message:")
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -92,7 +92,7 @@ class MultiParameterFunctionTest {
| 3
sum
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
@@ -107,7 +107,7 @@ class MultiParameterFunctionTest {
value = name == null || name.length == 5,
msg = "Message:"
)
""".trimIndent()
""".trimIndent(),
)
assertEquals(
"""
@@ -125,7 +125,7 @@ class MultiParameterFunctionTest {
msg = "Message:"
)
""".trimIndent(),
actual.trim()
actual.trim(),
)
}
}
@@ -145,7 +145,7 @@ fun main() {
$mainBody
}
""",
trimIndent = false
trimIndent = false,
)
val result = compile(listOf(file), PowerAssertComponentRegistrar(setOf(FqName("dbg"))))
@@ -31,7 +31,7 @@ class RegexMatchTest {
| [A-Za-z]+
false
""".trimIndent(),
actual
actual,
)
}
@@ -46,7 +46,7 @@ class RegexMatchTest {
| [A-Za-z]+
false
""".trimIndent(),
actual
actual,
)
}
}
@@ -27,12 +27,12 @@ import kotlin.test.assertEquals
import kotlin.test.fail
private val DEFAULT_COMPONENT_REGISTRARS = arrayOf(
PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert")))
PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert"))),
)
fun compile(
list: List<SourceFile>,
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS,
): KotlinCompilation.Result {
return KotlinCompilation().apply {
sources = list
@@ -53,7 +53,7 @@ fun compile(
fun executeAssertion(
@Language("kotlin") source: String,
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS,
): String {
val result = compile(
listOf(SourceFile.kotlin("main.kt", source, trimIndent = false)),
@@ -80,13 +80,13 @@ fun executeMainAssertion(mainBody: String) = executeAssertion(
fun main() {
$mainBody
}
"""
""",
)
fun assertMessage(
@Language("kotlin") source: String,
message: String,
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS
vararg plugins: ComponentRegistrar = DEFAULT_COMPONENT_REGISTRARS,
) {
val actual = executeAssertion(source, *plugins)
assertEquals(message, actual)