Fix up formatting issues
This commit is contained in:
+5
-5
@@ -229,11 +229,11 @@ class PowerAssertCallTransformer(
|
|||||||
private fun isStringSupertype(type: IrType): Boolean =
|
private fun isStringSupertype(type: IrType): Boolean =
|
||||||
context.irBuiltIns.stringType.isSubtypeOf(type, context.irBuiltIns)
|
context.irBuiltIns.stringType.isSubtypeOf(type, context.irBuiltIns)
|
||||||
|
|
||||||
private fun IrType.isAssignableTo(type: IrType): Boolean =
|
private fun IrType.isAssignableTo(type: IrType): Boolean {
|
||||||
isSubtypeOf(type, context.irBuiltIns) ||
|
if (isSubtypeOf(type, context.irBuiltIns)) return true
|
||||||
((type.classifierOrNull as? IrTypeParameterSymbol)?.owner?.superTypes?.all {
|
val superTypes = (type.classifierOrNull as? IrTypeParameterSymbol)?.owner?.superTypes
|
||||||
isSubtypeOf(it, context.irBuiltIns)
|
return superTypes != null && superTypes.all { isSubtypeOf(it, context.irBuiltIns) }
|
||||||
} ?: false)
|
}
|
||||||
|
|
||||||
private fun MessageCollector.info(expression: IrElement, message: String) {
|
private fun MessageCollector.info(expression: IrElement, message: String) {
|
||||||
report(expression, CompilerMessageSeverity.INFO, message)
|
report(expression, CompilerMessageSeverity.INFO, message)
|
||||||
|
|||||||
@@ -2,24 +2,23 @@ package com.bnorm.power
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import kotlin.test.assertEquals
|
|
||||||
|
|
||||||
class AssertBooleanTest {
|
class AssertBooleanTest {
|
||||||
@Test
|
@Test
|
||||||
fun `test assertTrue transformation`() {
|
fun `test assertTrue transformation`() {
|
||||||
assertMessage(
|
assertMessage(
|
||||||
"""
|
"""
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
assertTrue(1 != 1)
|
assertTrue(1 != 1)
|
||||||
}""",
|
}""",
|
||||||
"""
|
"""
|
||||||
Assertion failed
|
Assertion failed
|
||||||
assertTrue(1 != 1)
|
assertTrue(1 != 1)
|
||||||
|
|
|
|
||||||
false
|
false
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
|
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -28,17 +27,17 @@ assertTrue(1 != 1)
|
|||||||
fun `test assertFalse transformation`() {
|
fun `test assertFalse transformation`() {
|
||||||
assertMessage(
|
assertMessage(
|
||||||
"""
|
"""
|
||||||
import kotlin.test.assertFalse
|
import kotlin.test.assertFalse
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
assertFalse(1 == 1)
|
assertFalse(1 == 1)
|
||||||
}""",
|
}""",
|
||||||
"""
|
"""
|
||||||
Assertion failed
|
Assertion failed
|
||||||
assertFalse(1 == 1)
|
assertFalse(1 == 1)
|
||||||
|
|
|
|
||||||
true
|
true
|
||||||
""".trimIndent(),
|
""".trimIndent(),
|
||||||
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse")))
|
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse")))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ import kotlin.test.assertEquals
|
|||||||
class DebugFunctionTest {
|
class DebugFunctionTest {
|
||||||
@Test
|
@Test
|
||||||
fun `debug function transformation`() {
|
fun `debug function transformation`() {
|
||||||
val actual = executeMainDebug("""
|
val actual = executeMainDebug(
|
||||||
|
"""
|
||||||
dbg(1 + 2 + 3)
|
dbg(1 + 2 + 3)
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"""
|
"""
|
||||||
dbg(1 + 2 + 3)
|
dbg(1 + 2 + 3)
|
||||||
@@ -27,9 +29,11 @@ class DebugFunctionTest {
|
|||||||
}
|
}
|
||||||
@Test
|
@Test
|
||||||
fun `debug function transformation with message`() {
|
fun `debug function transformation with message`() {
|
||||||
val actual = executeMainDebug("""
|
val actual = executeMainDebug(
|
||||||
|
"""
|
||||||
dbg(1 + 2 + 3, "Message:")
|
dbg(1 + 2 + 3, "Message:")
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"""
|
"""
|
||||||
Message:
|
Message:
|
||||||
|
|||||||
@@ -130,7 +130,8 @@ class PowerAssertTest {
|
|||||||
| |
|
| |
|
||||||
| Jane
|
| Jane
|
||||||
Hello, Jane
|
Hello, Jane
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -146,6 +147,7 @@ class PowerAssertTest {
|
|||||||
| |
|
| |
|
||||||
| Jane
|
| Jane
|
||||||
Hello, Jane
|
Hello, Jane
|
||||||
""".trimIndent())
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user