Get rid of reduntant jvm parts in tests

This commit is contained in:
Mikhael Bogdanov
2018-12-21 13:34:40 +01:00
parent f59b6a350f
commit d1efac617d
10 changed files with 22 additions and 34 deletions
+1 -3
View File
@@ -1,5 +1,3 @@
// TARGET_BACKEND: JVM
class A(var value: String) class A(var value: String)
fun box(): String { fun box(): String {
@@ -7,7 +5,7 @@ fun box(): String {
try { try {
test(a) test(a)
} catch(e: java.lang.RuntimeException) { } catch(e: RuntimeException) {
} }
@@ -1,5 +1,3 @@
// TARGET_BACKEND: JVM
class A(var value: String) class A(var value: String)
fun box(): String { fun box(): String {
@@ -7,7 +5,7 @@ fun box(): String {
try { try {
test(a) test(a)
} catch(e: java.lang.RuntimeException) { } catch(e: RuntimeException) {
} }
@@ -1,5 +1,3 @@
// TARGET_BACKEND: JVM
class A(var value: String) class A(var value: String)
fun box(): String { fun box(): String {
@@ -7,7 +5,7 @@ fun box(): String {
try { try {
test(a) test(a)
} catch(e: java.lang.RuntimeException) { } catch(e: RuntimeException) {
} }
@@ -1,9 +1,7 @@
// TARGET_BACKEND: JVM
fun box(): String { fun box(): String {
var cycle = true; var cycle = true;
while (true) { while (true) {
if (true || throw java.lang.RuntimeException()) { if (true || throw RuntimeException()) {
return "OK" return "OK"
} }
} }
+3 -6
View File
@@ -1,14 +1,11 @@
// TARGET_BACKEND: JVM
interface MyIterator<T> { interface MyIterator<T> {
operator fun hasNext() : Boolean operator fun hasNext() : Boolean
operator fun next() : T operator fun next() : T
} }
operator fun <T : Any> T?.iterator() = object : MyIterator<T> { operator fun <T : Any> T?.iterator() = object : MyIterator<T> {
var hasNext = this@iterator != null private var hasNext = this@iterator != null
private set
override fun hasNext() = hasNext override fun hasNext() = hasNext
override fun next() : T { override fun next() : T {
@@ -16,7 +13,7 @@ operator fun <T : Any> T?.iterator() = object : MyIterator<T> {
hasNext = false hasNext = false
return this@iterator!! return this@iterator!!
} }
throw java.util.NoSuchElementException() throw NoSuchElementException()
} }
} }
+2 -2
View File
@@ -1,9 +1,9 @@
// TARGET_BACKEND: JVM // WITH_RUNTIME
open class Base(val bar: String) open class Base(val bar: String)
class Foo(bar: String) : Base(bar) { class Foo(bar: String) : Base(bar) {
fun something() = (bar as java.lang.String).toUpperCase() fun something() = bar.toUpperCase()
} }
fun box() = Foo("ok").something() fun box() = Foo("ok").something()
@@ -1,13 +1,13 @@
// TARGET_BACKEND: JVM // IGNORE_BACKEND: JS_IR, NATIVE
// WITH_RUNTIME // WITH_RUNTIME
import kotlin.test.assertTrue
fun check(x: Any?): Boolean { fun check(x: Any?): Boolean {
if (x is Int) { if (x is Int) {
return x in 239..240 return x in 239..240
} }
throw java.lang.AssertionError() throw AssertionError()
} }
fun check(x: Any?, l: Any?, r: Any?): Boolean { fun check(x: Any?, l: Any?, r: Any?): Boolean {
@@ -15,14 +15,14 @@ fun check(x: Any?, l: Any?, r: Any?): Boolean {
return x in l..r return x in l..r
} }
throw java.lang.AssertionError() throw AssertionError()
} }
fun box(): String { fun box(): String {
assert(check(239)) assertTrue(check(239))
assert(check(239, 239, 240)) assertTrue(check(239, 239, 240))
assert(!check(238)) assertTrue(!check(238))
assert(!check(238, 239, 240)) assertTrue(!check(238, 239, 240))
return "OK" return "OK"
} }
@@ -1,5 +1,5 @@
// TARGET_BACKEND: JVM
// FILE: 1.kt // FILE: 1.kt
// WITH_RUNTIME
class My(val value: Int) class My(val value: Int)
@@ -7,7 +7,7 @@ inline fun <T, R> T.perform(job: (T)-> R) : R {
return job(this) return job(this)
} }
public inline fun String.toInt2() : Int = java.lang.Integer.parseInt(this) public inline fun String.toInt2() : Int = this.toInt()
// FILE: 2.kt // FILE: 2.kt
@@ -1,5 +1,5 @@
// TARGET_BACKEND: JVM
// FILE: 1.kt // FILE: 1.kt
// WITH_RUNTIME
class My(val value: Int) class My(val value: Int)
@@ -19,7 +19,7 @@ inline fun <T, R> T.performWithFail2(job: (T)-> R, failJob : (e: RuntimeExceptio
} }
} }
public inline fun String.toInt2() : Int = java.lang.Integer.parseInt(this) public inline fun String.toInt2() : Int = this.toInt()
// FILE: 2.kt // FILE: 2.kt
@@ -1,4 +1,3 @@
// TARGET_BACKEND: JVM
// FILE: 1.kt // FILE: 1.kt
// WITH_RUNTIME // WITH_RUNTIME
@@ -22,7 +21,7 @@ inline fun <T, R> T.performWithFailFinally(job: (T)-> R, failJob : (e: RuntimeEx
} }
} }
inline fun String.toInt2() : Int = java.lang.Integer.parseInt(this) inline fun String.toInt2() : Int = this.toInt()
// FILE: 2.kt // FILE: 2.kt