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,22 @@
package foo
class A {
fun component1(): Int = 1
}
fun A.component2(): String = "n"
fun box(): String {
val list = Array<A>(1, { A() })
var i = 0;
var s = ""
for ((a, b) in list) {
i = a;
s = b;
}
if (i != 1) return "i != 1, it: " + i
if (s != "n") return "s != 'n', it: " + s
return "OK"
}
@@ -0,0 +1,41 @@
package foo
import java.util.HashMap
public inline fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> {
val entrySet = this.entrySet()
return entrySet.iterator()
}
/** Returns the key of the entry */
fun <K, V> Map.Entry<K, V>.component1(): K {
return getKey()
}
/** Returns the value of the entry */
fun <K, V> Map.Entry<K, V>.component2(): V {
return getValue()
}
fun box(): String {
val map = HashMap<Int, String>()
map.put(1, "s1")
map.put(2, "s2")
var s1 = ""
var s2 = ""
for ((k, v) in map) {
when (k) {
2 -> s2 = v
1 -> s1 = v
else -> {
}
}
}
if (s1 != "s1") return "s1 != 's1', it: ${s1}"
if (s2 != "s2") return "s2 != 's2', it: ${s2}"
return "OK"
}
@@ -0,0 +1,42 @@
package foo
class C(val i: Int) : Comparable<C>, A() {
public override fun compareTo(other: C): Int {
return if (other is C) other.i - i else 0
}
}
fun ComparableRange<C>.iterator(): Iterator<C> {
var curI: Int = start.i - 1
return object :Iterator<C> {
public override fun next(): C {
curI++
return C(curI)
}
public override fun hasNext(): Boolean {
return curI < end.i
}
}
}
open class A {
fun component1(): Int = 1
}
fun A.component2(): String = "n"
fun box(): String {
var i = 0;
var s = ""
for ((a, b) in C(0)..C(2)) {
i = a;
s = b;
}
if (i != 1) return "i != 1, it: " + i
if (s != "n") return "s != 'n', it: " + s
return "OK"
}
@@ -0,0 +1,25 @@
package foo
import java.util.ArrayList
class A {
fun component1(): Int = 1
}
fun A.component2(): String = "n"
fun box(): String {
val list = ArrayList<A>()
list.add(A())
var i = 0;
var s = ""
for ((a, b) in list) {
i = a;
s = b;
}
if (i != 1) return "i != 1, it: " + i
if (s != "n") return "s != 'n', it: " + s
return "OK"
}
@@ -0,0 +1,21 @@
package foo
fun Int.component1(): Int {
return this + 10;
}
fun Int.component2(): String = "b"
fun box(): String {
var i = 0;
var s = "";
for ((a, b) in 1..4) {
i = a
s = b
}
if (i != 14) return "i != 14, it: $i"
if (s != "b") return "s != 'b', it: $s"
return "OK"
}
@@ -0,0 +1,22 @@
package foo
fun Int.component1(): Int {
return this + 10;
}
fun Int.component2(): String = "b"
fun box(): String {
var i = 0;
var s = "";
val range = 1..4
for ((a, b) in range) {
i = a
s = b
}
if (i != 14) return "i != 14, it: $i"
if (s != "b") return "s != 'b', it: $s"
return "OK"
}
@@ -0,0 +1,41 @@
package foo
class A {
fun component1(): Int = 1
}
fun A.component2(): String = "n"
class B {
fun component1(): Int = 1
fun component2(): Int = 2
fun component3(): Int = 3
}
class C {
fun component1(): Int = 42
}
fun box(): String {
val (a, b) = A()
if (a != 1) return "a != 1, it: $a"
if (b != "n") return "b != 'n', it: $b"
var (x, y) = A()
if (x != 1) return "x != 1, it: $x"
if (y != "n") return "y != 'n', it: $y"
x = 3
if (x != 3) return "x != 3, it: $x"
y = "m"
if (y != "m") return "y != 'm', it: $y"
var (b1, b2, b3) = B()
if (b1 != 1) return "b1 != 1, it: $b1"
if (b2 != 2) return "b2 != 2, it: $b2"
if (b3 != 3) return "b3 != 3, it: $b3"
val (c) = C()
if (c != 42) return "c != 42, it: $c"
return "OK"
}