Support for conditional access calls
This commit is contained in:
@@ -149,7 +149,9 @@ fun buildAssertTree(expression: IrExpression): RootNode {
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
super.visitWhen(expression, data)
|
||||
// Add as basic expression and terminate
|
||||
// TODO this has to be broken and not work in all cases...
|
||||
ExpressionNode(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,6 +196,26 @@ assert(text == null || (text.length == 5 && text.toLowerCase() == text))
|
||||
| | Hello
|
||||
| false
|
||||
Hello
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun conditionalAccess() {
|
||||
assertMessage(
|
||||
"""
|
||||
fun main() {
|
||||
val text: String? = "Hello"
|
||||
assert(text?.length?.minus(2) == 1)
|
||||
}""",
|
||||
"""
|
||||
Assertion failed
|
||||
assert(text?.length?.minus(2) == 1)
|
||||
| | | |
|
||||
| | | false
|
||||
| | 3
|
||||
| 5
|
||||
Hello
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user