JS backend: testFiles -> testData
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun div(other: A) = "hooray"
|
||||
|
||||
}
|
||||
|
||||
fun box() = ((A() / A()) == "hooray")
|
||||
@@ -0,0 +1,11 @@
|
||||
package foo
|
||||
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
fun compareTo(other: A) = (this.i - other.i)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
return (A(3) > A(2)) && (A(2) >= A(2)) && (A(1) >= A(0)) && (A(2) <= A(2)) && (A(3) <= A(4)) && (A(0) < A(100))
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun not() = "hooray"
|
||||
|
||||
}
|
||||
|
||||
fun box() = (!A() == "hooray")
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package foo
|
||||
|
||||
class MyInt(i: Int) {
|
||||
var b = i
|
||||
fun inc(): MyInt {
|
||||
b = b + 1;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
class A() {
|
||||
|
||||
var gc = 0
|
||||
var sc = 0
|
||||
|
||||
|
||||
var b = MyInt(0)
|
||||
get() {
|
||||
gc = gc + 1;
|
||||
return $b;
|
||||
}
|
||||
set(a: MyInt) {
|
||||
sc = sc + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
val t = A()
|
||||
val d = t.b++;
|
||||
return (t.sc == 1) && (t.gc == 1);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package foo
|
||||
|
||||
import java.util.*
|
||||
|
||||
class ArrayWrapper<T>() {
|
||||
val contents = ArrayList<T>()
|
||||
|
||||
fun add(item: T) {
|
||||
contents.add(item)
|
||||
}
|
||||
|
||||
fun plusAssign(rhs: ArrayWrapper<T>) {
|
||||
contents.addAll(rhs.contents)
|
||||
}
|
||||
|
||||
fun get(index: Int): T {
|
||||
return contents.get(index)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var v1 = ArrayWrapper<String>()
|
||||
val v2 = ArrayWrapper<String>()
|
||||
v1.add("foo")
|
||||
v2.add("bar")
|
||||
v1 += v2
|
||||
return if (v1.contents.size() == 2) "OK" else "fail"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package foo
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T> ArrayList<T>.plusAssign(other: Collection<T>) {
|
||||
addAll(other)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var v1 = ArrayList<String>()
|
||||
val v2 = ArrayList<String>()
|
||||
v1.add("foo")
|
||||
v2.add("bar")
|
||||
v1 += v2
|
||||
return (v1.size() == 2 && v1[0] == "foo" && v1[1] == "bar")
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package foo
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T> ArrayList<T>.plus(other: Collection<T>): List<T> {
|
||||
val c = ArrayList<T>()
|
||||
c.addAll(this)
|
||||
c.addAll(other)
|
||||
return c
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var v1 = ArrayList<String>()
|
||||
val v2 = ArrayList<String>()
|
||||
v1.add("foo")
|
||||
v2.add("bar")
|
||||
v1 += v2
|
||||
return (v1.size() == 2 && v1[0] == "foo" && v1[1] == "bar")
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package foo
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T> ArrayList<T>.plus(other: Collection<T>): List<T> {
|
||||
val c = ArrayList<T>()
|
||||
c.addAll(this)
|
||||
c.addAll(other)
|
||||
return c
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var v1 = ArrayList<String>()
|
||||
v1.add("foo")
|
||||
val v2 = ArrayList<String>()
|
||||
v2.add("bar")
|
||||
val v = v1 + v2
|
||||
|
||||
return (v.size() == 2 && v[0] == "foo" && v[1] == "bar")
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package foo
|
||||
|
||||
class A(val c: Int) {
|
||||
}
|
||||
|
||||
|
||||
fun A.inc() = A(5)
|
||||
fun A.dec() = A(10)
|
||||
|
||||
fun box(): Boolean {
|
||||
var a = A(1)
|
||||
return ((++a).c == 5 && (a++).c == 5 && (--a).c == 10 && (a--).c == 10)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package foo
|
||||
|
||||
var a = MyInt()
|
||||
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun inc(): MyInt {
|
||||
val res = MyInt();
|
||||
res.b = b;
|
||||
res.b++;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
a++;
|
||||
a++;
|
||||
return (a.b == 2);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun plus() = "hooray"
|
||||
fun minus() = "not really"
|
||||
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = A()
|
||||
return (+c + -c == "hooraynot really")
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
var message = ""
|
||||
fun plusAssign(other: A) {
|
||||
message = message + "!"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = A()
|
||||
c += A()
|
||||
c += A()
|
||||
return c.message == "!!"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package foo
|
||||
|
||||
class myInt(a: Int) {
|
||||
val value = a;
|
||||
|
||||
fun plus(other: myInt): myInt = myInt(value + other.value)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
return (myInt(3) + myInt(5)).value == 8
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun inc(): MyInt {
|
||||
val res = MyInt()
|
||||
res.b++;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = MyInt()
|
||||
c++;
|
||||
return (c.b == 1);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
var a = MyInt()
|
||||
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun inc(): MyInt {
|
||||
b = b + 1;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
val d = a++;
|
||||
return (a.b == 1) && (d.b == 1);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun dec(): MyInt {
|
||||
val res = MyInt()
|
||||
res.b++;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = MyInt()
|
||||
--c;
|
||||
return (c.b == 1);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package foo
|
||||
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun dec(): MyInt {
|
||||
b = b + 1;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = MyInt()
|
||||
val d = --c;
|
||||
return (c.b == 1);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package foo
|
||||
|
||||
class MyInt(i: Int) {
|
||||
var b = i
|
||||
fun inc(): MyInt {
|
||||
b = b++;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var t = MyInt(0)
|
||||
t++;
|
||||
return (t.b == 0)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package foo
|
||||
|
||||
class MyInt(i: Int) {
|
||||
var b = i
|
||||
fun inc(): MyInt {
|
||||
b++;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var t = MyInt(0)
|
||||
t++;
|
||||
return (t.b == 1)
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
var p = "yeah"
|
||||
fun mod(other: A): A {
|
||||
return A();
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = A()
|
||||
val d = c;
|
||||
c %= A();
|
||||
return (c != d) && (c.p == "yeah")
|
||||
}
|
||||
Reference in New Issue
Block a user