backend/tests: Add blackbox tests from Kotlin JVM

Added tests from testData/codegen/box directory. There are blackbox tests
in other directories and they are to be added.
This commit is contained in:
Ilya Matveev
2017-01-12 19:43:20 +07:00
parent d5988297b1
commit 1b553ebfaf
2643 changed files with 66666 additions and 0 deletions
@@ -0,0 +1,15 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
fun box(): String {
OUTER@while (true) {
var x = ""
try {
do {
x = x + break@OUTER
} while (true)
} finally {
return "OK"
}
}
}
@@ -0,0 +1,10 @@
fun box(): String {
val ok: String? = "OK"
var res = ""
do {
res += ok ?: break
} while (false)
return res
}
@@ -0,0 +1,9 @@
fun test(str: String): String {
var s = ""
for (i in 1..3) {
s += if (i<2) str else break
}
return s
}
fun box(): String = test("OK")
@@ -0,0 +1,6 @@
fun box(): String {
var i = 0
do continue while (i++ < 3)
return "OK"
}
@@ -0,0 +1,7 @@
fun box(): String {
var s = "OK"
for (i in 1..3) {
s = s + if (i<2) "" else continue
}
return s
}
@@ -0,0 +1,17 @@
inline fun bar(block: () -> String) : String {
return block()
}
inline fun bar2() : String {
while (true) break
return bar { return "def" }
}
fun foobar(x: String, y: String, z: String) = x + y + z
fun box(): String {
val test = foobar("abc", bar2(), "ghi")
return if (test == "abcdefghi")
"OK"
else "Failed, test=$test"
}
@@ -0,0 +1,9 @@
fun box(): String {
var x = "OK"
do {
while (true) {
x = x + break
}
} while (false)
return x
}
@@ -0,0 +1,11 @@
fun foo(x: String): String {
var y: String
do {
y = x
} while (y != x.bar(x))
return y
}
inline fun String.bar(other: String) = this
fun box(): String = foo("OK")
@@ -0,0 +1,9 @@
fun box(): String {
var cycle = true;
while (true) {
if (true && break) {
return "fail"
}
}
return "OK"
}
@@ -0,0 +1,9 @@
fun box(): String {
var cycle = true;
while (true) {
if (true || break) {
return "OK"
}
}
return "fail"
}
@@ -0,0 +1,13 @@
fun foo(x: Long, y: Int, z: Double, s: String) {}
fun box(): String {
while (true) {
try {
foo(0, 0, 0.0, "" + continue)
}
finally {
foo(0, 0, 0.0, "" + break)
}
}
return "OK"
}
@@ -0,0 +1,12 @@
fun box(): String {
var x = "OK"
while (true) {
try {
x = x + continue
}
finally {
x = x + break
}
}
return x
}
@@ -0,0 +1,13 @@
fun box(): String {
var r = ""
for (i in 1..1) {
try {
r += "O"
break
} finally {
r += "K"
continue
}
}
return r
}
@@ -0,0 +1,4 @@
fun box(): String {
while (true) break
return "OK"
}