JS: move more test to box tests
This commit is contained in:
Vendored
Vendored
Vendored
Vendored
Vendored
Vendored
Vendored
Vendored
Vendored
Vendored
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
operator fun div(other: A) = "OK"
|
||||
|
||||
}
|
||||
|
||||
fun box() = A() / A()
|
||||
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
operator fun compareTo(other: A) = (this.i - other.i)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A(3) <= A(2)) return "fail1"
|
||||
if (A(2) < A(2)) return "fail2"
|
||||
if (A(1) < A(0)) return "fail3"
|
||||
if (A(2) > A(2)) return "fail4"
|
||||
if (A(3) > A(4)) return "fail5"
|
||||
if (A(0) >= A(100)) return "fail6"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package foo
|
||||
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
infix operator fun compareTo(other: A) = (this.i - other.i)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A(3) compareTo A(2) <= 0) return "fail1"
|
||||
if (A(2) compareTo A(2) != 0) return "fail2"
|
||||
if (A(1) compareTo A(0) <= 0) return "fail3"
|
||||
if (A(3) compareTo A(4) >= 0) return "fail4"
|
||||
if (A(0) compareTo A(100) >= 0) return "fail5"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
operator fun not() = "OK"
|
||||
|
||||
}
|
||||
|
||||
fun box() = !A()
|
||||
+5
-3
@@ -25,8 +25,10 @@ class A() {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val t = A()
|
||||
val d = t.b++;
|
||||
return (t.sc == 1) && (t.gc == 1);
|
||||
val d = t.b++
|
||||
if (t.sc != 1) return "fail1"
|
||||
if (t.gc != 1) return "fail2"
|
||||
return "OK"
|
||||
}
|
||||
+6
-2
@@ -12,12 +12,16 @@ operator fun <T> A<T>.plusAssign(other: Collection<T>) {
|
||||
addAll(other)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var v1 = arrayListOf("foo")
|
||||
val v2 = listOf("bar")
|
||||
|
||||
val a = A(v1)
|
||||
a += v2
|
||||
|
||||
return (v1.size == 2 && v1[0] == "foo" && v1[1] == "bar")
|
||||
if (v1.size != 2) return "fail1: ${v1.size}"
|
||||
if (v1[0] != "foo") return "fail2: ${v1[0]}"
|
||||
if (v1[1] != "bar") return "fail3: ${v1[1]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -9,8 +9,8 @@ operator fun <T> Foo<T>.plus(x: T): Foo<T> = Foo(x)
|
||||
operator fun <T> MutableFoo<T>.plus(x: T): MutableFoo<T> = MutableFoo(x)
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var f = MutableFoo(1)
|
||||
f += 2
|
||||
return (f is MutableFoo && f.value == 2)
|
||||
return if (f is MutableFoo && f.value == 2) "OK" else "fail"
|
||||
}
|
||||
+6
-2
@@ -9,12 +9,16 @@ operator fun <T> ArrayList<T>.plus(other: Collection<T>): List<T> {
|
||||
return c
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
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")
|
||||
if (v.size != 2) return "fail1: ${v.size}"
|
||||
if (v[0] != "foo") return "fail2: ${v[0]}"
|
||||
if (v[1] != "bar") return "fail3: ${v[1]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
package foo
|
||||
|
||||
class A(val c: Int) {
|
||||
}
|
||||
|
||||
|
||||
operator fun A.inc() = A(5)
|
||||
operator fun A.dec() = A(10)
|
||||
|
||||
fun box(): String {
|
||||
var a = A(1)
|
||||
|
||||
if ((++a).c != 5) return "fail1"
|
||||
if ((a++).c != 5) return "fail2"
|
||||
if ((--a).c != 10) return "fail3"
|
||||
if ((a--).c != 10) return "fail4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -14,8 +14,8 @@ class MyInt() {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
a++;
|
||||
a++;
|
||||
return (a.b == 2);
|
||||
return if (a.b == 2) "OK" else "fail"
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
operator fun unaryPlus() = "O"
|
||||
operator fun unaryMinus() = "K"
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var c = A()
|
||||
return +c + -c
|
||||
}
|
||||
+2
-2
@@ -9,9 +9,9 @@ class A() {
|
||||
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var c = A()
|
||||
c += A()
|
||||
c += A()
|
||||
return c.message == "!!"
|
||||
return if (c.message == "!!") return "OK" else "fail"
|
||||
}
|
||||
+2
-2
@@ -6,7 +6,7 @@ class myInt(a: Int) {
|
||||
operator fun plus(other: myInt): myInt = myInt(value + other.value)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
|
||||
return (myInt(3) + myInt(5)).value == 8
|
||||
return if ((myInt(3) + myInt(5)).value == 8) "OK" else "fail"
|
||||
}
|
||||
+2
-2
@@ -11,8 +11,8 @@ class MyInt() {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var c = MyInt()
|
||||
c++;
|
||||
return (c.b == 1);
|
||||
return if (c.b == 1) "OK" else "fail"
|
||||
}
|
||||
+6
-2
@@ -12,7 +12,11 @@ class MyInt() {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val d = a++;
|
||||
return (a.b == 1) && (d.b == 1);
|
||||
|
||||
if (a.b != 1) return "fail1: ${a.b}"
|
||||
if (d.b != 1) return "fail2: ${d.b}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -11,8 +11,8 @@ class MyInt() {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var c = MyInt()
|
||||
--c;
|
||||
return (c.b == 1);
|
||||
return if (c.b == 1) "OK" else "fail: ${c.b}"
|
||||
}
|
||||
+2
-2
@@ -10,8 +10,8 @@ class MyInt() {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var c = MyInt()
|
||||
val d = --c;
|
||||
return (c.b == 1);
|
||||
return if (c.b == 1) "OK" else "fail: ${c.b}"
|
||||
}
|
||||
+2
-2
@@ -8,8 +8,8 @@ class MyInt(i: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var t = MyInt(0)
|
||||
t++;
|
||||
return (t.b == 0)
|
||||
return if (t.b == 0) "OK" else "fail: ${t.b}"
|
||||
}
|
||||
+2
-2
@@ -8,8 +8,8 @@ class MyInt(i: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var t = MyInt(0)
|
||||
t++;
|
||||
return (t.b == 1)
|
||||
return if (t.b == 1) "OK" else "fail: ${t.b}"
|
||||
}
|
||||
+2
-2
@@ -7,9 +7,9 @@ class A() {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var c = A()
|
||||
val d = c;
|
||||
c %= A();
|
||||
return (c != d) && (c.p == "yeah")
|
||||
return if ((c != d) && (c.p == "yeah")) "OK" else "fail"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
operator fun div(other: A) = "hooray"
|
||||
|
||||
}
|
||||
|
||||
fun box() = ((A() / A()) == "hooray")
|
||||
@@ -1,11 +0,0 @@
|
||||
package foo
|
||||
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
operator 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))
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package foo
|
||||
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
infix operator fun compareTo(other: A) = (this.i - other.i)
|
||||
}
|
||||
|
||||
fun box(): Boolean =
|
||||
(A(3) compareTo A(2) > 0) &&
|
||||
(A(2) compareTo A(2) == 0) &&
|
||||
(A(1) compareTo A(0) > 0) &&
|
||||
(A(3) compareTo A(4) < 0) &&
|
||||
(A(0) compareTo A(100) < 0)
|
||||
@@ -1,9 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
operator fun not() = "hooray"
|
||||
|
||||
}
|
||||
|
||||
fun box() = (!A() == "hooray")
|
||||
Vendored
-13
@@ -1,13 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A(val c: Int) {
|
||||
}
|
||||
|
||||
|
||||
operator fun A.inc() = A(5)
|
||||
operator 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)
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
operator fun unaryPlus() = "hooray"
|
||||
operator fun unaryMinus() = "not really"
|
||||
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
var c = A()
|
||||
return (+c + -c == "hooraynot really")
|
||||
}
|
||||
Reference in New Issue
Block a user