@@ -36,14 +36,6 @@ abstract class PowerAssertGenerator(
|
|||||||
private val file: IrFile,
|
private val file: IrFile,
|
||||||
private val fileSource: String
|
private val fileSource: String
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// private fun IrStatementsBuilder<*>.buildAssertThrow(
|
|
||||||
// callSource: String,
|
|
||||||
// title: IrExpression,
|
|
||||||
// subStack: MutableList<IrStackVariable>,
|
|
||||||
// callIndent: Int = 0
|
|
||||||
// ) = buildThrow(constructor, buildMessage(title, subStack, callSource, callIndent))
|
|
||||||
|
|
||||||
abstract fun IrBuilderWithScope.buildAssertThrow(subStack: List<IrStackVariable>): IrExpression
|
abstract fun IrBuilderWithScope.buildAssertThrow(subStack: List<IrStackVariable>): IrExpression
|
||||||
|
|
||||||
fun buildAssert(
|
fun buildAssert(
|
||||||
@@ -107,7 +99,12 @@ abstract class PowerAssertGenerator(
|
|||||||
|
|
||||||
var startColumnNumber = file.info(expression).startColumnNumber
|
var startColumnNumber = file.info(expression).startColumnNumber
|
||||||
if (expression is IrMemberAccessExpression) {
|
if (expression is IrMemberAccessExpression) {
|
||||||
// TODO Is this the best way to fix indentation of infix operators?
|
val descriptor = expression.descriptor
|
||||||
|
if (descriptor is FunctionDescriptor && descriptor.isInfix) {
|
||||||
|
startColumnNumber += source.indexOf(descriptor.name.asString())
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO handle equality and comparison better?
|
||||||
startColumnNumber += when (expression.origin) {
|
startColumnNumber += when (expression.origin) {
|
||||||
IrStatementOrigin.EQEQ, IrStatementOrigin.EQEQEQ -> source.indexOf("==")
|
IrStatementOrigin.EQEQ, IrStatementOrigin.EQEQEQ -> source.indexOf("==")
|
||||||
IrStatementOrigin.EXCLEQ, IrStatementOrigin.EXCLEQEQ -> source.indexOf("!=")
|
IrStatementOrigin.EXCLEQ, IrStatementOrigin.EXCLEQEQ -> source.indexOf("!=")
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.bnorm.power
|
|||||||
import com.tschuchort.compiletesting.KotlinCompilation
|
import com.tschuchort.compiletesting.KotlinCompilation
|
||||||
import com.tschuchort.compiletesting.SourceFile
|
import com.tschuchort.compiletesting.SourceFile
|
||||||
import org.intellij.lang.annotations.Language
|
import org.intellij.lang.annotations.Language
|
||||||
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
@@ -265,6 +266,23 @@ assert(text?.length?.minus(2) == 1)
|
|||||||
| | 3
|
| | 3
|
||||||
| 5
|
| 5
|
||||||
Hello
|
Hello
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun infixFunctions() {
|
||||||
|
assertMessage(
|
||||||
|
"""
|
||||||
|
fun main() {
|
||||||
|
assert(1 shl 1 == 4)
|
||||||
|
}""",
|
||||||
|
"""
|
||||||
|
Assertion failed
|
||||||
|
assert(1 shl 1 == 4)
|
||||||
|
| |
|
||||||
|
| false
|
||||||
|
2
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user