JS backend: testFiles -> testData

This commit is contained in:
Zalim Bashorov
2014-02-26 15:39:46 +04:00
parent bcd579acdd
commit 442215e829
490 changed files with 0 additions and 0 deletions
@@ -0,0 +1,9 @@
package foo
fun box(): Boolean {
val a = arrayOfNulls<Int>(2)
a.set(1, 2)
return a.get(1) == 2
}
@@ -0,0 +1,8 @@
package foo
fun box(): Boolean {
val a = arrayOfNulls<Int>(4)
a[1] = 2
a[2] = 3
return (a[1] == 2) && (a[2] == 3)
}
@@ -0,0 +1,28 @@
package foo
class Fail(val message: String) : Exception(message)
native fun eval(arg: String): Any? = noImpl
fun test(testName: String, actual: Any, expectedAsString: String) {
val expected = eval("[$expectedAsString]")
if (actual != expected) throw Fail("Wrong result for '$testName' function. Expected: $expected | Actual: $actual")
}
fun box(): String {
try {
test("array", array(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("booleanArray", booleanArray(true, false, false, true, true), "true, false, false, true, true")
test("charArray'", charArray('0', '1', '2', '3', '4'), "'0', '1', '2', '3', '4'")
test("byteArray", byteArray(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("shortArray", shortArray(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("intArray,", intArray(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("longArray", longArray(0, 1, 2, 3, 4), "0, 1, 2, 3, 4")
test("floatArray", floatArray(0.0.toFloat(), 1.0.toFloat(), 2.0.toFloat(), 3.0.toFloat(), 4.0.toFloat()), "0.0, 1.0, 2.0, 3.0, 4.0")
test("doubleArray", doubleArray(0.0, 1.1, 2.2, 3.3, 4.4), "0.0, 1.1, 2.2, 3.3, 4.4")
}
catch (e: Fail) {
return e.message
}
return "OK"
}
@@ -0,0 +1,7 @@
package foo
val f = {(i: Int) -> i + 1 }
val a = Array(3, f)
fun box() = (a[0] == 1 && a[2] == 3 && a[1] == 2)
@@ -0,0 +1,5 @@
package foo
val a = arrayOfNulls<Int>(3)
fun box() = (a[0] == null && a[1] == null && a[2] == null)
@@ -0,0 +1,9 @@
package foo
class A() {
}
val a1 = arrayOfNulls<Int>(3)
val a2 = arrayOfNulls<A>(2)
fun box() = (a1.size == 3 && a2.size == 2)
@@ -0,0 +1,9 @@
package foo
class A() {
}
val a1 = Array<Int>(3)
val a2 = Array<A>(2)
fun box() = (a1[4] == null)
@@ -0,0 +1,11 @@
package foo
val a1 = Array<Int>(3, {(i: Int) -> i })
fun box(): Boolean {
val i = a1.iterator()
return ((i.hasNext() == true) && (i.next() == 0) &&
(i.hasNext() == true) && (i.next() == 1) &&
(i.hasNext() == true) && (i.next() == 2) &&
(i.hasNext() == false));
}
@@ -0,0 +1,12 @@
package foo
fun box(): String {
val s = StringBuilder()
s.append("a")
s.append("b").append("c")
s.append('d').append("e")
if (s.toString() != "abcde") return s.toString()
return "OK"
}