Files
kotlin-fork/compiler/testData/codegen/box/smap/infixCalls.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

69 lines
1.5 KiB
Kotlin
Vendored

// This test depends on line numbers.
// TARGET_BACKEND: JVM
// WITH_STDLIB
// FULL_JDK
package test
fun testProperLineNumber(): String {
var exceptionCount = 0;
try {
test() fail
call()
}
catch(e: AssertionError) {
val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1)
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:10" != actual) {
return "fail 1: ${actual}"
}
exceptionCount++
}
try {
call() fail
test()
}
catch(e: AssertionError) {
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:23" != actual) {
return "fail 1: ${actual}"
}
exceptionCount++
}
try {
call() fail test()
}
catch(e: AssertionError) {
val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:36" != actual) {
return "fail 1: ${actual}"
}
exceptionCount++
}
return if (exceptionCount == 3) "OK" else "fail"
}
fun box(): String {
return testProperLineNumber()
}
public fun checkEquals(p1: String, p2: String) {
throw AssertionError("fail")
}
inline fun test(): String {
return "123"
}
infix fun String.fail(p: String): String {
throw AssertionError("fail")
}
fun call(): String {
return "xxx"
}