JS: move expressions test to box tests

This commit is contained in:
Alexey Andreev
2016-08-26 19:32:17 +03:00
parent 2bf0199959
commit b159049be8
314 changed files with 2380 additions and 2185 deletions
@@ -0,0 +1,11 @@
package foo
fun box(): String {
try {
if (true) throw Exception() else "fail1"
}
catch (e: Exception) {
return "OK"
}
return "fail2"
}
@@ -0,0 +1,43 @@
// http://youtrack.jetbrains.com/issue/KT-5594
// JS: compiler crashes
package foo
fun bar(f: () -> Unit) {
}
fun test() {
bar {
// val actionId: Any = 1
val item: Any? = 1
if (item != null) {
// In original version, as I remember, `when` was an important to reproduce, but now it is not.
// when(actionId){
// 1 -> { 1 }
// "2" -> { "2"}
// else -> {}
// }
}
}
bar {
val actionId: Any = 1
val item: Any? = 1
if (item != null) {
when (actionId) {
1 -> {
1
}
"2" -> {
"2"
}
else -> {
}
}
}
}
}
fun box(): String {
return "OK"
}
+35
View File
@@ -0,0 +1,35 @@
// JS: generate wrong code for nested if
// http://youtrack.jetbrains.com/issue/KT-5576
package foo
fun test2(a: Boolean, b: Boolean, c: Boolean) {
val a =
if (a) {
if (b) {
"1"
} else if (c) {
"2"
} else {
throw Exception("Rest parameter must be array types")
}
}
else {
"3"
}
}
fun box(): String {
test2(true, true, false)
var wasException = false
try {
test2(true, false, false)
}
catch(e: Exception) {
wasException = true
}
assertEquals(true, wasException)
return "OK"
}
@@ -0,0 +1,8 @@
package foo
fun box(): String {
var r = ""
if (r != "") else r += "O"
if (r == "O") r += "K" else;
return r
}