JS: move more test to box tests

This commit is contained in:
Alexey Andreev
2016-08-30 14:59:26 +03:00
parent 7e2d5b04de
commit 3801052460
112 changed files with 760 additions and 676 deletions
+22
View File
@@ -0,0 +1,22 @@
// KT-2470 another name mangling bug: kotlin.test.failsWith() gets generated to invalid JS
package foo
public fun <T : Throwable> failsWith(block: () -> Any): T {
try {
block()
}
catch (e: T) {
return e
}
throw Exception("Should have failed")
}
fun box(): String {
val a = failsWith<Exception> {
throw Exception("OK")
}
return a.message!!
}
@@ -0,0 +1,37 @@
package foo
val x: Int?
get() = null
// Note: `x ?: 2` expression used to force to create tempary variable
class A {
val a = x ?: 2
}
enum class E(val a: Int = 0) {
X(),
Y() {
val y = x ?: 4
override fun value() = y
};
val e = x ?: 3
open fun value() = e
}
open class B(val b: Int)
class C : B(x ?: 6)
fun box(): String {
assertEquals(2, A().a)
assertEquals(3, E.X.e)
assertEquals(4, E.Y.value())
assertEquals(6, C().b)
return "OK"
}