From d8167fe82b3b8ef79418ebf9cf41d644e6f5894b Mon Sep 17 00:00:00 2001 From: Brian Norman Date: Fri, 17 Nov 2023 10:23:40 -0600 Subject: [PATCH] [PowerAssert] Update base package --- .../gradle}/PowerAssertGradleExtension.kt | 2 +- .../gradle}/PowerAssertGradlePlugin.kt | 2 +- .../jetbrains/kotlin/powerassert}/IrUtils.kt | 2 +- .../PowerAssertCallTransformer.kt | 24 +- .../PowerAssertIrGenerationExtension.kt | 4 +- .../powerassert}/delegate/FunctionDelegate.kt | 2 +- .../delegate/LambdaFunctionDelegate.kt | 4 +- .../SamConversionLambdaFunctionDelegate.kt | 4 +- .../delegate/SimpleFunctionDelegate.kt | 2 +- .../powerassert}/diagram/DiagramBuilder.kt | 2 +- .../powerassert}/diagram/ExpressionTree.kt | 2 +- .../kotlin/powerassert}/diagram/IrDiagram.kt | 30 +- .../diagram/IrTemporaryVariable.kt | 2 +- .../kotlin/powerassert}/diagram/SourceFile.kt | 2 +- .../PowerAssertCommandLineProcessor.kt | 2 +- .../PowerAssertCompilerPluginRegistrar.kt | 3 +- .../bnorm/power/ArithmeticExpressionTest.kt | 162 -------- .../com/bnorm/power/CastExpressionTest.kt | 73 ---- .../test/com/bnorm/power/Compiler.kt | 92 ----- .../test/com/bnorm/power/DebugFunctionTest.kt | 105 ----- .../test/com/bnorm/power/InfixFunctionTest.kt | 369 ------------------ .../test/com/bnorm/power/ObjectLiteralTest.kt | 39 -- .../test/com/bnorm/power/RegexMatchTest.kt | 52 --- .../test/com/bnorm/power/VarargTest.kt | 43 -- 24 files changed, 45 insertions(+), 979 deletions(-) rename libraries/tools/kotlin-power-assert/src/{main/kotlin/com/bnorm/power => common/kotlin/org/jetbrains/kotlin/powerassert/gradle}/PowerAssertGradleExtension.kt (93%) rename libraries/tools/kotlin-power-assert/src/{main/kotlin/com/bnorm/power => common/kotlin/org/jetbrains/kotlin/powerassert/gradle}/PowerAssertGradlePlugin.kt (97%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/IrUtils.kt (98%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/PowerAssertCallTransformer.kt (94%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/PowerAssertIrGenerationExtension.kt (93%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/delegate/FunctionDelegate.kt (97%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/delegate/LambdaFunctionDelegate.kt (94%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/delegate/SamConversionLambdaFunctionDelegate.kt (95%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/delegate/SimpleFunctionDelegate.kt (96%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/diagram/DiagramBuilder.kt (98%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/diagram/ExpressionTree.kt (99%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/diagram/IrDiagram.kt (93%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/diagram/IrTemporaryVariable.kt (97%) rename plugins/power-assert/power-assert.backend/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/diagram/SourceFile.kt (97%) rename plugins/power-assert/power-assert.cli/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/PowerAssertCommandLineProcessor.kt (97%) rename plugins/power-assert/power-assert.cli/src/{com/bnorm/power => org/jetbrains/kotlin/powerassert}/PowerAssertCompilerPluginRegistrar.kt (94%) delete mode 100644 plugins/power-assert/test/com/bnorm/power/ArithmeticExpressionTest.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/CastExpressionTest.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/Compiler.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/DebugFunctionTest.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/InfixFunctionTest.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/ObjectLiteralTest.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/RegexMatchTest.kt delete mode 100644 plugins/power-assert/test/com/bnorm/power/VarargTest.kt diff --git a/libraries/tools/kotlin-power-assert/src/main/kotlin/com/bnorm/power/PowerAssertGradleExtension.kt b/libraries/tools/kotlin-power-assert/src/common/kotlin/org/jetbrains/kotlin/powerassert/gradle/PowerAssertGradleExtension.kt similarity index 93% rename from libraries/tools/kotlin-power-assert/src/main/kotlin/com/bnorm/power/PowerAssertGradleExtension.kt rename to libraries/tools/kotlin-power-assert/src/common/kotlin/org/jetbrains/kotlin/powerassert/gradle/PowerAssertGradleExtension.kt index 151f9cfa1c5..606fd57a46b 100644 --- a/libraries/tools/kotlin-power-assert/src/main/kotlin/com/bnorm/power/PowerAssertGradleExtension.kt +++ b/libraries/tools/kotlin-power-assert/src/common/kotlin/org/jetbrains/kotlin/powerassert/gradle/PowerAssertGradleExtension.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert.gradle open class PowerAssertGradleExtension { var functions: List = listOf("kotlin.assert") diff --git a/libraries/tools/kotlin-power-assert/src/main/kotlin/com/bnorm/power/PowerAssertGradlePlugin.kt b/libraries/tools/kotlin-power-assert/src/common/kotlin/org/jetbrains/kotlin/powerassert/gradle/PowerAssertGradlePlugin.kt similarity index 97% rename from libraries/tools/kotlin-power-assert/src/main/kotlin/com/bnorm/power/PowerAssertGradlePlugin.kt rename to libraries/tools/kotlin-power-assert/src/common/kotlin/org/jetbrains/kotlin/powerassert/gradle/PowerAssertGradlePlugin.kt index aa061a55b3c..17b81e50d44 100644 --- a/libraries/tools/kotlin-power-assert/src/main/kotlin/com/bnorm/power/PowerAssertGradlePlugin.kt +++ b/libraries/tools/kotlin-power-assert/src/common/kotlin/org/jetbrains/kotlin/powerassert/gradle/PowerAssertGradlePlugin.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert.gradle import org.gradle.api.Project import org.gradle.api.provider.Provider diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/IrUtils.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/IrUtils.kt similarity index 98% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/IrUtils.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/IrUtils.kt index 6e1f201962d..403717be79f 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/IrUtils.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/IrUtils.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder import org.jetbrains.kotlin.descriptors.DescriptorVisibilities diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/PowerAssertCallTransformer.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/PowerAssertCallTransformer.kt similarity index 94% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/PowerAssertCallTransformer.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/PowerAssertCallTransformer.kt index 58e20cbb87d..20da13694a7 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/PowerAssertCallTransformer.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/PowerAssertCallTransformer.kt @@ -14,19 +14,19 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert -import com.bnorm.power.delegate.FunctionDelegate -import com.bnorm.power.delegate.LambdaFunctionDelegate -import com.bnorm.power.delegate.SamConversionLambdaFunctionDelegate -import com.bnorm.power.delegate.SimpleFunctionDelegate -import com.bnorm.power.diagram.IrTemporaryVariable -import com.bnorm.power.diagram.Node -import com.bnorm.power.diagram.SourceFile -import com.bnorm.power.diagram.buildDiagramNesting -import com.bnorm.power.diagram.buildDiagramNestingNullable -import com.bnorm.power.diagram.buildTree -import com.bnorm.power.diagram.irDiagramString +import org.jetbrains.kotlin.powerassert.delegate.FunctionDelegate +import org.jetbrains.kotlin.powerassert.delegate.LambdaFunctionDelegate +import org.jetbrains.kotlin.powerassert.delegate.SamConversionLambdaFunctionDelegate +import org.jetbrains.kotlin.powerassert.delegate.SimpleFunctionDelegate +import org.jetbrains.kotlin.powerassert.diagram.IrTemporaryVariable +import org.jetbrains.kotlin.powerassert.diagram.Node +import org.jetbrains.kotlin.powerassert.diagram.SourceFile +import org.jetbrains.kotlin.powerassert.diagram.buildDiagramNesting +import org.jetbrains.kotlin.powerassert.diagram.buildDiagramNestingNullable +import org.jetbrains.kotlin.powerassert.diagram.buildTree +import org.jetbrains.kotlin.powerassert.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 diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/PowerAssertIrGenerationExtension.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/PowerAssertIrGenerationExtension.kt similarity index 93% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/PowerAssertIrGenerationExtension.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/PowerAssertIrGenerationExtension.kt index f194d2120d9..3b59f38b912 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/PowerAssertIrGenerationExtension.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/PowerAssertIrGenerationExtension.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert -import com.bnorm.power.diagram.SourceFile +import org.jetbrains.kotlin.powerassert.diagram.SourceFile import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext import org.jetbrains.kotlin.cli.common.messages.MessageCollector diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/FunctionDelegate.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/FunctionDelegate.kt similarity index 97% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/FunctionDelegate.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/FunctionDelegate.kt index d9980d3a551..8eb4e0f547c 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/FunctionDelegate.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/FunctionDelegate.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power.delegate +package org.jetbrains.kotlin.powerassert.delegate import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope import org.jetbrains.kotlin.ir.builders.irCall diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/LambdaFunctionDelegate.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/LambdaFunctionDelegate.kt similarity index 94% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/LambdaFunctionDelegate.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/LambdaFunctionDelegate.kt index d59f1bf2ff4..9356ac2a0ed 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/LambdaFunctionDelegate.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/LambdaFunctionDelegate.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.bnorm.power.delegate +package org.jetbrains.kotlin.powerassert.delegate -import com.bnorm.power.irLambda +import org.jetbrains.kotlin.powerassert.irLambda import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope import org.jetbrains.kotlin.ir.builders.irReturn import org.jetbrains.kotlin.ir.declarations.IrValueParameter diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/SamConversionLambdaFunctionDelegate.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/SamConversionLambdaFunctionDelegate.kt similarity index 95% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/SamConversionLambdaFunctionDelegate.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/SamConversionLambdaFunctionDelegate.kt index d3ecc484cff..0d040d3a423 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/SamConversionLambdaFunctionDelegate.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/SamConversionLambdaFunctionDelegate.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.bnorm.power.delegate +package org.jetbrains.kotlin.powerassert.delegate -import com.bnorm.power.irLambda +import org.jetbrains.kotlin.powerassert.irLambda import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope import org.jetbrains.kotlin.ir.builders.irReturn import org.jetbrains.kotlin.ir.builders.irSamConversion diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/SimpleFunctionDelegate.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/SimpleFunctionDelegate.kt similarity index 96% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/SimpleFunctionDelegate.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/SimpleFunctionDelegate.kt index e78447696e9..6c605433bca 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/delegate/SimpleFunctionDelegate.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/delegate/SimpleFunctionDelegate.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power.delegate +package org.jetbrains.kotlin.powerassert.delegate import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope import org.jetbrains.kotlin.ir.declarations.IrValueParameter diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/DiagramBuilder.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/DiagramBuilder.kt similarity index 98% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/DiagramBuilder.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/DiagramBuilder.kt index 875ef9d6d06..337ea37bc71 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/DiagramBuilder.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/DiagramBuilder.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power.diagram +package org.jetbrains.kotlin.powerassert.diagram import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope import org.jetbrains.kotlin.ir.builders.irBlock diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/ExpressionTree.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/ExpressionTree.kt similarity index 99% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/ExpressionTree.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/ExpressionTree.kt index f5e95357130..d5d80ab1b59 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/ExpressionTree.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/ExpressionTree.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power.diagram +package org.jetbrains.kotlin.powerassert.diagram import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.expressions.IrCall diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/IrDiagram.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/IrDiagram.kt similarity index 93% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/IrDiagram.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/IrDiagram.kt index 96c80ab28c2..38be0a363c3 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/IrDiagram.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/IrDiagram.kt @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.bnorm.power.diagram +package org.jetbrains.kotlin.powerassert.diagram -import com.bnorm.power.irString +import org.jetbrains.kotlin.powerassert.irString import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.SourceRangeInfo import org.jetbrains.kotlin.ir.builders.IrBuilderWithScope @@ -35,10 +35,10 @@ import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall import org.jetbrains.kotlin.ir.expressions.addArgument fun IrBuilderWithScope.irDiagramString( - sourceFile: SourceFile, - prefix: IrExpression? = null, - call: IrCall, - variables: List, + sourceFile: SourceFile, + prefix: IrExpression? = null, + call: IrCall, + variables: List, ): IrExpression { val callInfo = sourceFile.getSourceRangeInfo(call) val callIndent = callInfo.startColumnNumber @@ -99,9 +99,9 @@ private data class ValueDisplay( ) private fun IrTemporaryVariable.toValueDisplay( - fileSource: SourceFile, - callIndent: Int, - originalInfo: SourceRangeInfo, + fileSource: SourceFile, + callIndent: Int, + originalInfo: SourceRangeInfo, ): ValueDisplay { val info = fileSource.getSourceRangeInfo(original) var indent = info.startColumnNumber - callIndent @@ -156,9 +156,9 @@ private fun IrTemporaryVariable.toValueDisplay( * ``` */ private fun findDisplayOffset( - sourceFile: SourceFile, - expression: IrExpression, - source: String, + sourceFile: SourceFile, + expression: IrExpression, + source: String, ): Int { return when (expression) { is IrMemberAccessExpression<*> -> memberAccessOffset(sourceFile, expression, source) @@ -168,9 +168,9 @@ private fun findDisplayOffset( } private fun memberAccessOffset( - sourceFile: SourceFile, - expression: IrMemberAccessExpression<*>, - source: String, + sourceFile: SourceFile, + expression: IrMemberAccessExpression<*>, + source: String, ): Int { when (expression.origin) { // special case to handle `value != null` diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/IrTemporaryVariable.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/IrTemporaryVariable.kt similarity index 97% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/IrTemporaryVariable.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/IrTemporaryVariable.kt index 710195c9f2a..7b02bcde038 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/IrTemporaryVariable.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/IrTemporaryVariable.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power.diagram +package org.jetbrains.kotlin.powerassert.diagram import org.jetbrains.kotlin.ir.builders.IrStatementsBuilder import org.jetbrains.kotlin.ir.builders.irGet diff --git a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/SourceFile.kt b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/SourceFile.kt similarity index 97% rename from plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/SourceFile.kt rename to plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/SourceFile.kt index 45387004d66..40372b51a48 100644 --- a/plugins/power-assert/power-assert.backend/src/com/bnorm/power/diagram/SourceFile.kt +++ b/plugins/power-assert/power-assert.backend/src/org/jetbrains/kotlin/powerassert/diagram/SourceFile.kt @@ -1,4 +1,4 @@ -package com.bnorm.power.diagram +package org.jetbrains.kotlin.powerassert.diagram import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation import org.jetbrains.kotlin.ir.IrElement diff --git a/plugins/power-assert/power-assert.cli/src/com/bnorm/power/PowerAssertCommandLineProcessor.kt b/plugins/power-assert/power-assert.cli/src/org/jetbrains/kotlin/powerassert/PowerAssertCommandLineProcessor.kt similarity index 97% rename from plugins/power-assert/power-assert.cli/src/com/bnorm/power/PowerAssertCommandLineProcessor.kt rename to plugins/power-assert/power-assert.cli/src/org/jetbrains/kotlin/powerassert/PowerAssertCommandLineProcessor.kt index 599d69a9111..eebe6d28712 100644 --- a/plugins/power-assert/power-assert.cli/src/com/bnorm/power/PowerAssertCommandLineProcessor.kt +++ b/plugins/power-assert/power-assert.cli/src/org/jetbrains/kotlin/powerassert/PowerAssertCommandLineProcessor.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert import com.google.auto.service.AutoService import org.jetbrains.kotlin.compiler.plugin.AbstractCliOption diff --git a/plugins/power-assert/power-assert.cli/src/com/bnorm/power/PowerAssertCompilerPluginRegistrar.kt b/plugins/power-assert/power-assert.cli/src/org/jetbrains/kotlin/powerassert/PowerAssertCompilerPluginRegistrar.kt similarity index 94% rename from plugins/power-assert/power-assert.cli/src/com/bnorm/power/PowerAssertCompilerPluginRegistrar.kt rename to plugins/power-assert/power-assert.cli/src/org/jetbrains/kotlin/powerassert/PowerAssertCompilerPluginRegistrar.kt index 50148950958..3140672b6b6 100644 --- a/plugins/power-assert/power-assert.cli/src/com/bnorm/power/PowerAssertCompilerPluginRegistrar.kt +++ b/plugins/power-assert/power-assert.cli/src/org/jetbrains/kotlin/powerassert/PowerAssertCompilerPluginRegistrar.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.bnorm.power +package org.jetbrains.kotlin.powerassert import com.google.auto.service.AutoService import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension @@ -24,6 +24,7 @@ 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 +import org.jetbrains.kotlin.powerassert.PowerAssertIrGenerationExtension val KEY_FUNCTIONS = CompilerConfigurationKey>("fully-qualified function names") diff --git a/plugins/power-assert/test/com/bnorm/power/ArithmeticExpressionTest.kt b/plugins/power-assert/test/com/bnorm/power/ArithmeticExpressionTest.kt deleted file mode 100644 index 1ec3a311f20..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/ArithmeticExpressionTest.kt +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2020 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import kotlin.test.Test -import kotlin.test.assertEquals - -class ArithmeticExpressionTest { - @Test - fun `assertion with inline addition`() { - val actual = executeMainAssertion("assert(1 + 1 == 4)") - assertEquals( - """ - Assertion failed - assert(1 + 1 == 4) - | | - | false - 2 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline subtraction`() { - val actual = executeMainAssertion("assert(3 - 1 == 4)") - assertEquals( - """ - Assertion failed - assert(3 - 1 == 4) - | | - | false - 2 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline multiplication`() { - val actual = executeMainAssertion("assert(1 * 2 == 4)") - assertEquals( - """ - Assertion failed - assert(1 * 2 == 4) - | | - | false - 2 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline division`() { - val actual = executeMainAssertion("assert(2 / 1 == 4)") - assertEquals( - """ - Assertion failed - assert(2 / 1 == 4) - | | - | false - 2 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline prefix increment`() { - val actual = executeMainAssertion( - """ - var i = 1 - assert(++i == 4) - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - assert(++i == 4) - | | - | false - 2 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline postfix increment`() { - val actual = executeMainAssertion( - """ - var i = 1 - assert(i++ == 4) - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - assert(i++ == 4) - | | - | false - 1 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline prefix decrement`() { - val actual = executeMainAssertion( - """ - var i = 3 - assert(--i == 4) - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - assert(--i == 4) - | | - | false - 2 - """.trimIndent(), - actual, - ) - } - - @Test - fun `assertion with inline postfix decrement`() { - val actual = executeMainAssertion( - """ - var i = 3 - assert(i-- == 4) - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - assert(i-- == 4) - | | - | false - 3 - """.trimIndent(), - actual, - ) - } -} diff --git a/plugins/power-assert/test/com/bnorm/power/CastExpressionTest.kt b/plugins/power-assert/test/com/bnorm/power/CastExpressionTest.kt deleted file mode 100644 index 546adbc739a..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/CastExpressionTest.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2022 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import kotlin.test.Test -import kotlin.test.assertEquals - -class CastExpressionTest { - @Test - fun `instance check is correctly aligned`() { - val actual = executeMainAssertion("""assert(null is String)""") - assertEquals( - """ - Assertion failed - assert(null is String) - | - false - """.trimIndent(), - actual, - ) - } - - @Test - fun `negative instance check is correctly aligned`() { - val actual = executeMainAssertion("""assert("Hello, world!" !is String)""") - assertEquals( - """ - Assertion failed - assert("Hello, world!" !is String) - | - false - """.trimIndent(), - actual, - ) - } - - @Test - fun `smart casts do not duplicate output`() { - val actual = executeMainAssertion( - """ - val greeting: Any = "hello" - assert(greeting is String && greeting.length == 2) - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - assert(greeting is String && greeting.length == 2) - | | | | | - | | | | false - | | | 5 - | | hello - | true - hello - """.trimIndent(), - actual, - ) - } -} diff --git a/plugins/power-assert/test/com/bnorm/power/Compiler.kt b/plugins/power-assert/test/com/bnorm/power/Compiler.kt deleted file mode 100644 index 126d67ead98..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/Compiler.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (C) 2020 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -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.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_COMPILER_PLUGIN_REGISTRARS = arrayOf( - PowerAssertCompilerPluginRegistrar(setOf(FqName("kotlin.assert"))), -) - -fun compile( - list: List, - vararg compilerPluginRegistrars: CompilerPluginRegistrar = DEFAULT_COMPILER_PLUGIN_REGISTRARS, -): KotlinCompilation.Result { - return KotlinCompilation().apply { - sources = list - messageOutputStream = object : OutputStream() { - override fun write(b: Int) { - // black hole all writes - } - - override fun write(b: ByteArray, off: Int, len: Int) { - // black hole all writes - } - } - this.compilerPluginRegistrars = compilerPluginRegistrars.toList() - inheritClassPath = true - }.compile() -} - -fun executeAssertion( - @Language("kotlin") source: String, - vararg compilerPluginRegistrars: CompilerPluginRegistrar = DEFAULT_COMPILER_PLUGIN_REGISTRARS, -): String { - val result = compile( - listOf(SourceFile.kotlin("main.kt", source, trimIndent = false)), - *compilerPluginRegistrars, - ) - assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode, result.messages) - - val kClazz = result.classLoader.loadClass("MainKt") - val main = kClazz.declaredMethods.single { it.name == "main" && it.parameterCount == 0 } - try { - try { - main.invoke(null) - } catch (t: InvocationTargetException) { - throw t.cause!! - } - fail("should have thrown assertion") - } catch (t: Throwable) { - return t.message ?: "" - } -} - -fun executeMainAssertion(mainBody: String) = executeAssertion( - """ -fun main() { - $mainBody -} -""", -) - -fun assertMessage( - @Language("kotlin") source: String, - message: String, - vararg compilerPluginRegistrars: CompilerPluginRegistrar = DEFAULT_COMPILER_PLUGIN_REGISTRARS, -) { - val actual = executeAssertion(source, *compilerPluginRegistrars) - assertEquals(message, actual) -} diff --git a/plugins/power-assert/test/com/bnorm/power/DebugFunctionTest.kt b/plugins/power-assert/test/com/bnorm/power/DebugFunctionTest.kt deleted file mode 100644 index cc4ca96b46e..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/DebugFunctionTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2021 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import com.tschuchort.compiletesting.KotlinCompilation -import com.tschuchort.compiletesting.SourceFile -import org.jetbrains.kotlin.name.FqName -import java.lang.reflect.InvocationTargetException -import java.lang.reflect.Method -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.fail - -class DebugFunctionTest { - @Test - fun `debug function transformation`() { - val actual = executeMainDebug( - """ - dbg(1 + 2 + 3) - """.trimIndent(), - ) - assertEquals( - """ - dbg(1 + 2 + 3) - | | - | 6 - 3 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `debug function transformation with message`() { - val actual = executeMainDebug( - """ - dbg(1 + 2 + 3, "Message:") - """.trimIndent(), - ) - assertEquals( - """ - Message: - dbg(1 + 2 + 3, "Message:") - | | - | 6 - 3 - """.trimIndent(), - actual.trim(), - ) - } -} - -private fun executeMainDebug(mainBody: String): String { - val file = SourceFile.kotlin( - name = "main.kt", - contents = """ -fun dbg(value: T): T = value - -fun dbg(value: T, msg: String): T { - throw RuntimeException("result:"+msg) - return value -} - -fun main() { - $mainBody -} -""", - trimIndent = false, - ) - - val result = compile(listOf(file), PowerAssertCompilerPluginRegistrar(setOf(FqName("dbg")))) - assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode) - - val kClazz = result.classLoader.loadClass("MainKt") - val main = kClazz.declaredMethods.single { it.name == "main" && it.parameterCount == 0 } - return getMainResult(main) -} - -fun getMainResult(main: Method): String { - try { - main.invoke(null) - fail("main did not throw expected exception") - } catch (t: InvocationTargetException) { - with(t.cause) { - if (this is RuntimeException && message != null && message!!.startsWith("result:")) { - return message!!.substringAfter("result:") - } - } - throw t.cause!! - } -} diff --git a/plugins/power-assert/test/com/bnorm/power/InfixFunctionTest.kt b/plugins/power-assert/test/com/bnorm/power/InfixFunctionTest.kt deleted file mode 100644 index 26368fb8511..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/InfixFunctionTest.kt +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright (C) 2022 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import com.tschuchort.compiletesting.KotlinCompilation -import com.tschuchort.compiletesting.SourceFile -import org.jetbrains.kotlin.name.FqName -import java.lang.reflect.InvocationTargetException -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.fail - -class InfixFunctionTest { - @Test - fun `extension infix function call includes receiver`() { - val actual = runExtensionInfix( - """ - (1 + 1) mustEqual (2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - (1 + 1) mustEqual (2 + 4) - | | - | 6 - 2 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension infix function call with constant receiver`() { - val actual = runExtensionInfix( - """ - 1 mustEqual (2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - 1 mustEqual (2 + 4) - | - 6 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension infix function call with constant parameter`() { - val actual = runExtensionInfix( - """ - (1 + 1) mustEqual 6 - """.trimIndent(), - ) - assertEquals( - """ - (1 + 1) mustEqual 6 - | - 2 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension infix function call with only constants`() { - val actual = runExtensionInfix( - """ - 2 mustEqual 6 - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension non-infix function call includes receiver`() { - val actual = runExtensionInfix( - """ - (1 + 1).mustEqual(2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - (1 + 1).mustEqual(2 + 4) - | | - | 6 - 2 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension non-infix function call with constant receiver`() { - val actual = runExtensionInfix( - """ - 1.mustEqual(2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - 1.mustEqual(2 + 4) - | - 6 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension non-infix function call with constant parameter`() { - val actual = runExtensionInfix( - """ - (1 + 1).mustEqual(6) - """.trimIndent(), - ) - assertEquals( - """ - (1 + 1).mustEqual(6) - | - 2 - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `extension non-infix function call with only constants`() { - val actual = runExtensionInfix( - """ - 2.mustEqual(6) - """.trimIndent(), - ) - assertEquals( - """ - Assertion failed - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch infix function call includes receiver`() { - val actual = runDispatchInfix( - """ - Wrapper(1 + 1) mustEqual (2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(1 + 1) mustEqual (2 + 4) - | | | - | | 6 - | 2 - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch infix function call with constant receiver`() { - val actual = runDispatchInfix( - """ - Wrapper(1) mustEqual (2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(1) mustEqual (2 + 4) - | | - | 6 - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch infix function call with constant parameter`() { - val actual = runDispatchInfix( - """ - Wrapper(1 + 1) mustEqual 6 - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(1 + 1) mustEqual 6 - | | - | 2 - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch infix function call with only constants`() { - val actual = runDispatchInfix( - """ - Wrapper(2) mustEqual 6 - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(2) mustEqual 6 - | - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch non-infix function call includes receiver`() { - val actual = runDispatchInfix( - """ - Wrapper(1 + 1).mustEqual(2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(1 + 1).mustEqual(2 + 4) - | | | - | | 6 - | 2 - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch non-infix function call with constant receiver`() { - val actual = runDispatchInfix( - """ - Wrapper(1).mustEqual(2 + 4) - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(1).mustEqual(2 + 4) - | | - | 6 - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch non-infix function call with constant parameter`() { - val actual = runDispatchInfix( - """ - Wrapper(1 + 1).mustEqual(6) - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(1 + 1).mustEqual(6) - | | - | 2 - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - @Test - fun `dispatch non-infix function call with only constants`() { - val actual = runDispatchInfix( - """ - Wrapper(2).mustEqual(6) - """.trimIndent(), - ) - assertEquals( - """ - Wrapper(2).mustEqual(6) - | - Wrapper - """.trimIndent(), - actual.trim(), - ) - } - - private fun runExtensionInfix(mainBody: String): String { - return run( - SourceFile.kotlin( - name = "main.kt", - contents = """ - infix fun V.mustEqual(expected: V): Unit = assert(this == expected) - - fun V.mustEqual(expected: V, message: () -> String): Unit = - assert(this == expected, message) - - fun main() { - $mainBody - } - """.trimIndent(), - trimIndent = false, - ), - setOf(FqName("mustEqual")), - ) - } - - private fun runDispatchInfix(mainBody: String): String { - return run( - SourceFile.kotlin( - name = "main.kt", - contents = """ - class Wrapper( - private val value: V - ) { - infix fun mustEqual(expected: V): Unit = assert(value == expected) - - fun mustEqual(expected: V, message: () -> String): Unit = - assert(value == expected, message) - - override fun toString() = "Wrapper" - } - - fun main() { - $mainBody - } - """.trimIndent(), - trimIndent = false, - ), - setOf(FqName("Wrapper.mustEqual")), - ) - } - - private fun run(file: SourceFile, fqNames: Set, main: String = "MainKt"): String { - val result = compile(listOf(file), PowerAssertCompilerPluginRegistrar(fqNames)) - assertEquals(KotlinCompilation.ExitCode.OK, result.exitCode, "Failed with messages: " + result.messages) - - val kClazz = result.classLoader.loadClass(main) - val mainMethod = kClazz.declaredMethods.single { it.name == "main" && it.parameterCount == 0 } - try { - try { - mainMethod.invoke(null) - } catch (t: InvocationTargetException) { - throw t.cause!! - } - fail("should have thrown assertion") - } catch (t: Throwable) { - return t.message ?: "" - } - } -} diff --git a/plugins/power-assert/test/com/bnorm/power/ObjectLiteralTest.kt b/plugins/power-assert/test/com/bnorm/power/ObjectLiteralTest.kt deleted file mode 100644 index c7d04fbdae7..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/ObjectLiteralTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2023 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import kotlin.test.Test - -class ObjectLiteralTest { - @Test - fun `internals of object literal should not be separated`() { - assertMessage( - """ - fun main() { - assert(object { override fun toString() = "ANONYMOUS" }.toString() == "toString()") - }""", - """ - Assertion failed - assert(object { override fun toString() = "ANONYMOUS" }.toString() == "toString()") - | | | - | | false - | ANONYMOUS - ANONYMOUS - """.trimIndent(), - ) - } -} diff --git a/plugins/power-assert/test/com/bnorm/power/RegexMatchTest.kt b/plugins/power-assert/test/com/bnorm/power/RegexMatchTest.kt deleted file mode 100644 index fd806cfaf90..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/RegexMatchTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2021 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import kotlin.test.Test -import kotlin.test.assertEquals - -class RegexMatchTest { - @Test - fun `regex matches`() { - val actual = executeMainAssertion("""assert("Hello, World".matches("[A-Za-z]+".toRegex()))""") - assertEquals( - """ - Assertion failed - assert("Hello, World".matches("[A-Za-z]+".toRegex())) - | | - | [A-Za-z]+ - false - """.trimIndent(), - actual, - ) - } - - @Test - fun `infix regex matches`() { - val actual = executeMainAssertion("""assert("Hello, World" matches "[A-Za-z]+".toRegex())""") - assertEquals( - """ - Assertion failed - assert("Hello, World" matches "[A-Za-z]+".toRegex()) - | | - | [A-Za-z]+ - false - """.trimIndent(), - actual, - ) - } -} diff --git a/plugins/power-assert/test/com/bnorm/power/VarargTest.kt b/plugins/power-assert/test/com/bnorm/power/VarargTest.kt deleted file mode 100644 index 77062d55942..00000000000 --- a/plugins/power-assert/test/com/bnorm/power/VarargTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2023 Brian Norman - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.bnorm.power - -import kotlin.test.Test - -class VarargTest { - @Test - fun `implicit array of vararg parameters is excluded from diagram`() { - assertMessage( - """ - fun main() { - var i = 0 - assert(listOf("a", "b", "c") == listOf(i++, i++, i++)) - }""", - """ - Assertion failed - assert(listOf("a", "b", "c") == listOf(i++, i++, i++)) - | | | | | | - | | | | | 2 - | | | | 1 - | | | 0 - | | [0, 1, 2] - | false - [a, b, c] - """.trimIndent(), - ) - } -}