Fix up formatting issues

This commit is contained in:
Brian Norman
2021-04-04 17:58:05 -05:00
parent ce119c9d92
commit 8d73179c89
4 changed files with 37 additions and 32 deletions
@@ -229,11 +229,11 @@ class PowerAssertCallTransformer(
private fun isStringSupertype(type: IrType): Boolean =
context.irBuiltIns.stringType.isSubtypeOf(type, context.irBuiltIns)
private fun IrType.isAssignableTo(type: IrType): Boolean =
isSubtypeOf(type, context.irBuiltIns) ||
((type.classifierOrNull as? IrTypeParameterSymbol)?.owner?.superTypes?.all {
isSubtypeOf(it, context.irBuiltIns)
} ?: false)
private fun IrType.isAssignableTo(type: IrType): Boolean {
if (isSubtypeOf(type, context.irBuiltIns)) return true
val superTypes = (type.classifierOrNull as? IrTypeParameterSymbol)?.owner?.superTypes
return superTypes != null && superTypes.all { isSubtypeOf(it, context.irBuiltIns) }
}
private fun MessageCollector.info(expression: IrElement, message: String) {
report(expression, CompilerMessageSeverity.INFO, message)
@@ -2,24 +2,23 @@ package com.bnorm.power
import org.jetbrains.kotlin.name.FqName
import org.junit.Test
import kotlin.test.assertEquals
class AssertBooleanTest {
@Test
fun `test assertTrue transformation`() {
assertMessage(
"""
import kotlin.test.assertTrue
fun main() {
assertTrue(1 != 1)
}""",
import kotlin.test.assertTrue
fun main() {
assertTrue(1 != 1)
}""",
"""
Assertion failed
assertTrue(1 != 1)
|
false
""".trimIndent(),
Assertion failed
assertTrue(1 != 1)
|
false
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertTrue")))
)
}
@@ -28,17 +27,17 @@ assertTrue(1 != 1)
fun `test assertFalse transformation`() {
assertMessage(
"""
import kotlin.test.assertFalse
fun main() {
assertFalse(1 == 1)
}""",
import kotlin.test.assertFalse
fun main() {
assertFalse(1 == 1)
}""",
"""
Assertion failed
assertFalse(1 == 1)
|
true
""".trimIndent(),
Assertion failed
assertFalse(1 == 1)
|
true
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertFalse")))
)
}
@@ -12,9 +12,11 @@ import kotlin.test.assertEquals
class DebugFunctionTest {
@Test
fun `debug function transformation`() {
val actual = executeMainDebug("""
val actual = executeMainDebug(
"""
dbg(1 + 2 + 3)
""".trimIndent())
""".trimIndent()
)
assertEquals(
"""
dbg(1 + 2 + 3)
@@ -27,9 +29,11 @@ class DebugFunctionTest {
}
@Test
fun `debug function transformation with message`() {
val actual = executeMainDebug("""
val actual = executeMainDebug(
"""
dbg(1 + 2 + 3, "Message:")
""".trimIndent())
""".trimIndent()
)
assertEquals(
"""
Message:
@@ -130,7 +130,8 @@ class PowerAssertTest {
| |
| Jane
Hello, Jane
""".trimIndent())
""".trimIndent()
)
}
@Test
@@ -146,6 +147,7 @@ class PowerAssertTest {
| |
| Jane
Hello, Jane
""".trimIndent())
""".trimIndent()
)
}
}