JS: move more test to box tests
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
|
||||
}
|
||||
|
||||
object test {
|
||||
var c = 2;
|
||||
var b = 1;
|
||||
}
|
||||
|
||||
object aWrapper {
|
||||
var a = A();
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (test.c != 2) return "fail1: ${test.c}"
|
||||
|
||||
if (test.b != 1) return "fail2: ${test.b}"
|
||||
test.c += 10
|
||||
if (test.c != 12) "fail3: ${test.c}"
|
||||
if (aWrapper.a !is A) "fail4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package foo
|
||||
|
||||
object State {
|
||||
val c = 2
|
||||
val b = 1
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (State.c != 2) return "fail1: ${State.c}"
|
||||
if (State.b != 1) return "fail2: ${State.b}"
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
fun f(): Boolean {
|
||||
fun f(): String {
|
||||
val z = object {
|
||||
val c = true
|
||||
val c = "OK"
|
||||
}
|
||||
return z.c
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class Foo {
|
||||
fun bar(param: String): String {
|
||||
val local = "world!"
|
||||
val local = "K"
|
||||
var a = object {
|
||||
val b = object {
|
||||
val bar = param + local
|
||||
@@ -12,7 +12,7 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
return Foo().bar("hello ") == "hello world!"
|
||||
fun box(): String {
|
||||
return Foo().bar("O")
|
||||
}
|
||||
|
||||
+3
-3
@@ -14,11 +14,11 @@ object foo : Foo {
|
||||
}
|
||||
}
|
||||
|
||||
private var result = false
|
||||
private var result = "fail"
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
foo.execute() {
|
||||
result = true
|
||||
result = "OK"
|
||||
}
|
||||
|
||||
return result
|
||||
+1
-1
@@ -6,4 +6,4 @@ abstract class A(val s: String) {
|
||||
object B : A("test") {
|
||||
}
|
||||
|
||||
fun box() = B.s == "test"
|
||||
fun box() = if (B.s == "test") "OK" else "fail: ${B.s}"
|
||||
+5
-5
@@ -6,17 +6,17 @@ class Test {
|
||||
fun b() = 2
|
||||
}
|
||||
|
||||
fun doTest(): Boolean {
|
||||
fun doTest(): String {
|
||||
if (a.c() != 3) {
|
||||
return false;
|
||||
return "fail1"
|
||||
}
|
||||
if (a.b() != 2) {
|
||||
return false;
|
||||
return "fail2"
|
||||
}
|
||||
return true;
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
return Test().doTest();
|
||||
}
|
||||
+2
-2
@@ -4,8 +4,8 @@ class Test() {
|
||||
var a: Int = 100
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var test = Test()
|
||||
test.a = 1
|
||||
return (1 == test.a)
|
||||
return if (1 == test.a) "OK" else "fail: ${test.a}"
|
||||
}
|
||||
+2
-2
@@ -9,9 +9,9 @@ class A() {
|
||||
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var c = A()
|
||||
c = A()
|
||||
c = A()
|
||||
return (a == 3)
|
||||
return if (a == 3) "OK" else "fail: $a"
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@ class Test() {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var test = Test()
|
||||
return (test.a == 5)
|
||||
return if (test.a == 5) "OK" else "fail: ${test.a}"
|
||||
}
|
||||
+2
-2
@@ -7,8 +7,8 @@ class Test() {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
var test = Test()
|
||||
test.a = 5
|
||||
return (test.a == 3)
|
||||
return if (test.a == 3) "OK" else "fail: ${test.a}"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// FILE: enumerable.kt
|
||||
package foo
|
||||
|
||||
@native
|
||||
fun <T> _enumerate(o: T): T = noImpl
|
||||
|
||||
@native
|
||||
fun <T> _findFirst(o: Any): T = noImpl
|
||||
|
||||
class Test() {
|
||||
val a: Int = 100
|
||||
val b: String = "s"
|
||||
}
|
||||
|
||||
class P() {
|
||||
@enumerable
|
||||
val a: Int = 100
|
||||
val b: String = "s"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val test = _enumerate(Test())
|
||||
val p = _enumerate(P())
|
||||
if (100 != test.a) return "fail1: ${test.a}"
|
||||
if ("s" != test.b) return "fail2: ${test.b}"
|
||||
if (p.a != 100) return "fail3: ${p.a}"
|
||||
|
||||
val result = _findFirst<Int>(object {
|
||||
val test = 100
|
||||
})
|
||||
if (result != 100) return "fail4: $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: enumerate.js
|
||||
function _enumerate(o) {
|
||||
var r = {};
|
||||
for (var p in o) {
|
||||
r[p] = o[p];
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function _findFirst(o) {
|
||||
for (var p in o) {
|
||||
return o[p];
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -2,13 +2,13 @@ package foo
|
||||
|
||||
fun f(a: Int?, b: Int.(Int) -> Int) = a?.b(2)
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val c1 = f (null) {
|
||||
it + this
|
||||
} != null
|
||||
if (c1) return false;
|
||||
if (c1) return "fail1"
|
||||
if (f(3) {
|
||||
it + this
|
||||
} != 5) return false
|
||||
return true;
|
||||
} != 5) return "fail2"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package foo
|
||||
|
||||
class Test() {
|
||||
val a: Int = 100
|
||||
var b: Int = a
|
||||
val c: Int = a + b
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val test = Test()
|
||||
if (100 != test.a) return "fail1: ${test.a}"
|
||||
if (100 != test.b) return "fail2: ${test.b}"
|
||||
if (200 != test.c) return "fail3: ${test.c}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+3
-3
@@ -6,7 +6,7 @@ interface I {
|
||||
|
||||
class P : I {
|
||||
override fun test(): String {
|
||||
return "a" + test("b")
|
||||
return "O" + test("K")
|
||||
}
|
||||
|
||||
private fun test(p: String): String {
|
||||
@@ -14,6 +14,6 @@ class P : I {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
return P().test() == "ab"
|
||||
fun box(): String {
|
||||
return P().test()
|
||||
}
|
||||
+2
-2
@@ -10,6 +10,6 @@ var a: Int
|
||||
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
return (a == 5)
|
||||
fun box(): String {
|
||||
return if (a == 5) "OK" else "fail: $a"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
val b = 3
|
||||
|
||||
fun box() = if (b == 3) "OK" else "fail: $b"
|
||||
@@ -0,0 +1,8 @@
|
||||
package foo
|
||||
|
||||
var b = 3
|
||||
|
||||
fun box(): String {
|
||||
b = 2
|
||||
return if (b == 2) "OK" else "fail: $b"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
val a: Int = 1
|
||||
}
|
||||
|
||||
class B() {
|
||||
val b: Int = 2
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A().a != 1) return "fail1"
|
||||
if (B().b != 2) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
|
||||
val intProgression = IntProgression.fromClosedRange(0, 10, 2)
|
||||
assertEquals(10, intProgression.last)
|
||||
@@ -11,5 +11,5 @@ fun box(): Boolean {
|
||||
val charProgression = CharProgression.fromClosedRange('a', 'z', 2)
|
||||
assertEquals('y', charProgression.last)
|
||||
|
||||
return true
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var twoToFive = IntRange(2, 5)
|
||||
|
||||
if (twoToFive.contains(6)) return "fail1"
|
||||
if (twoToFive.contains(1)) return "fail2"
|
||||
if (twoToFive.contains(0)) return "fail3"
|
||||
if (twoToFive.contains(-100)) return "fail4"
|
||||
if (twoToFive.contains(10)) return "fail5"
|
||||
if (!twoToFive.contains(2)) return "fail6"
|
||||
if (!twoToFive.contains(3)) return "fail7"
|
||||
if (!twoToFive.contains(4)) return "fail8"
|
||||
if (!twoToFive.contains(5)) return "fail9"
|
||||
if (!(twoToFive.start == 2)) return "fail10"
|
||||
if (!(twoToFive.endInclusive == 5)) return "fail11"
|
||||
|
||||
var sum = 0;
|
||||
for (i in twoToFive) {
|
||||
sum += i;
|
||||
}
|
||||
|
||||
if (sum != 14) return "fail12"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package foo
|
||||
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (1 in -2..0) return "fail1"
|
||||
if (1 in -10..-4) return "fail2"
|
||||
if (!(1 in 0..2)) return "fail3"
|
||||
|
||||
if (!(1 in 1..2)) return "fail4"
|
||||
if (!(1 in -2..5)) return "fail5"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box(): String {
|
||||
var elems = ArrayList<Int>()
|
||||
for (i in 0.rangeTo(5)) {
|
||||
elems.add(i)
|
||||
}
|
||||
if (elems[0] != 0) return "fail1: ${elems[0]}"
|
||||
if (elems[1] != 1) return "fail2: ${elems[1]}"
|
||||
if (elems[2] != 2) return "fail3: ${elems[2]}"
|
||||
if (elems[3] != 3) return "fail4: ${elems[3]}"
|
||||
if (elems[4] != 4) return "fail5: ${elems[4]}"
|
||||
if (elems[5] != 5) return "fail6: ${elems[5]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+6
-6
@@ -1,18 +1,18 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
|
||||
var d = 0
|
||||
for (i in 1..6) {
|
||||
d += i
|
||||
}
|
||||
if (d != 21) return false;
|
||||
if (d != 21) return "fail1: $d"
|
||||
|
||||
for (x in 100..199) {
|
||||
d += 1
|
||||
}
|
||||
if (d != 121) {
|
||||
return false;
|
||||
return "fail2: $d"
|
||||
}
|
||||
|
||||
for (y in 1..1) {
|
||||
@@ -20,7 +20,7 @@ fun box(): Boolean {
|
||||
}
|
||||
|
||||
if (d != 100) {
|
||||
return false;
|
||||
return "fail3: $d"
|
||||
}
|
||||
|
||||
for (c in 100..100) {
|
||||
@@ -28,8 +28,8 @@ fun box(): Boolean {
|
||||
}
|
||||
|
||||
if (d != 101) {
|
||||
return false;
|
||||
return "fail4: $d"
|
||||
}
|
||||
return true
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(true, 2..1 == 4..2, "2..1 == 4..2")
|
||||
assertEquals(true, 2L..1L == 318238945677L..2L, "2L..1L == 318238945677L..2L")
|
||||
assertEquals(false, (2..1) as Any == (4L..2L) as Any, "(2..1): Any == (4L..2L): Any")
|
||||
assertEquals(true, 'B'..'A' == 'W'..'B', "'B'..'A' == 'W'..'B'")
|
||||
assertEquals(false, (2..1) as Any == ('B'..'A') as Any, "(2..1): Any == ('B'..'A'): Any")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
|
||||
var twoToFive = 2..5
|
||||
|
||||
if (twoToFive.contains(6)) return "fail1"
|
||||
if (twoToFive.contains(1)) return "fail2"
|
||||
if (twoToFive.contains(0)) return "fail3"
|
||||
if (twoToFive.contains(-100)) return "fail4"
|
||||
if (twoToFive.contains(10)) return "fail5"
|
||||
if (!twoToFive.contains(2)) return "fail6"
|
||||
if (!twoToFive.contains(3)) return "fail7"
|
||||
if (!twoToFive.contains(4)) return "fail8"
|
||||
if (!twoToFive.contains(5)) return "fail9"
|
||||
if (!(twoToFive.start == 2)) return "fail10"
|
||||
if (!(twoToFive.endInclusive == 5)) return "fail11"
|
||||
|
||||
var sum = 0;
|
||||
for (i in twoToFive) {
|
||||
sum += i;
|
||||
}
|
||||
|
||||
if (sum != 14) return "fail12"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+3
-3
@@ -2,9 +2,9 @@ package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
for (i in 0.rangeTo(-1)) {
|
||||
return false
|
||||
return "fail"
|
||||
}
|
||||
return true
|
||||
return "OK"
|
||||
}
|
||||
Vendored
@@ -1,28 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A {
|
||||
|
||||
}
|
||||
|
||||
object test {
|
||||
var c = 2;
|
||||
var b = 1;
|
||||
}
|
||||
|
||||
object aWrapper {
|
||||
var a = A();
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
if (test.c != 2) return false;
|
||||
|
||||
if (test.b != 1) return false;
|
||||
test.c += 10
|
||||
if (test.c != 12) {
|
||||
return false;
|
||||
}
|
||||
if (aWrapper.a !is A) {
|
||||
return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package foo
|
||||
|
||||
object State {
|
||||
val c = 2
|
||||
val b = 1
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
if (State.c != 2) return false
|
||||
if (State.b != 1) return false
|
||||
return true
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package foo
|
||||
|
||||
@native
|
||||
fun <T> _enumerate(o: T): T = noImpl
|
||||
|
||||
@native
|
||||
fun <T> _findFirst(o: Any): T = noImpl
|
||||
|
||||
class Test() {
|
||||
val a: Int = 100
|
||||
val b: String = "s"
|
||||
}
|
||||
|
||||
class P() {
|
||||
@enumerable
|
||||
val a: Int = 100
|
||||
val b: String = "s"
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
val test = _enumerate(Test())
|
||||
val p = _enumerate(P())
|
||||
return (100 == test.a && "s" == test.b) && p.a == 100 && _findFirst<Int>(object {
|
||||
val test = 100
|
||||
}) == 100;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package foo
|
||||
|
||||
class Test() {
|
||||
val a: Int = 100
|
||||
var b: Int = a
|
||||
val c: Int = a + b
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
val test = Test()
|
||||
return (100 == test.a && 100 == test.b && 200 == test.c)
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package foo
|
||||
|
||||
val b = 3
|
||||
|
||||
fun box() = (b == 3)
|
||||
@@ -1,8 +0,0 @@
|
||||
package foo
|
||||
|
||||
var b = 3
|
||||
|
||||
fun box(): Boolean {
|
||||
b = 2
|
||||
return (b == 2)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
val a: Int = 1
|
||||
}
|
||||
|
||||
class B() {
|
||||
val b: Int = 2
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
return ((A().a == 1) && (B().b == 2));
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
function _enumerate(o) {
|
||||
var r = {};
|
||||
for (var p in o) {
|
||||
r[p] = o[p];
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function _findFirst(o) {
|
||||
for (var p in o) {
|
||||
return o[p];
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
var twoToFive = IntRange(2, 5)
|
||||
|
||||
if (twoToFive.contains(6)) return false;
|
||||
if (twoToFive.contains(1)) return false;
|
||||
if (twoToFive.contains(0)) return false;
|
||||
if (twoToFive.contains(-100)) return false;
|
||||
if (twoToFive.contains(10)) return false;
|
||||
if (!twoToFive.contains(2)) return false;
|
||||
if (!twoToFive.contains(3)) return false;
|
||||
if (!twoToFive.contains(4)) return false;
|
||||
if (!twoToFive.contains(5)) return false;
|
||||
if (!(twoToFive.start == 2)) return false;
|
||||
if (!(twoToFive.endInclusive == 5)) return false;
|
||||
|
||||
var sum = 0;
|
||||
for (i in twoToFive) {
|
||||
sum += i;
|
||||
}
|
||||
|
||||
if (sum != 14) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package foo
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
if (1 in -2..0) return false;
|
||||
if (1 in -10..-4) return false;
|
||||
if (!(1 in 0..2)) return false;
|
||||
|
||||
if (!(1 in 1..2)) return false;
|
||||
if (!(1 in -2..5)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package foo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun box(): Boolean {
|
||||
var elems = ArrayList<Int>()
|
||||
for (i in 0.rangeTo(5)) {
|
||||
elems.add(i)
|
||||
}
|
||||
return elems[0] == 0 && elems[1] == 1 && elems[2] == 2 && elems[3] == 3 && elems[4] == 4 && elems[5] == 5
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(true, 2..1 == 4..2, "2..1 == 4..2")
|
||||
assertEquals(true, 2L..1L == 318238945677L..2L, "2L..1L == 318238945677L..2L")
|
||||
assertEquals(false, (2..1) as Any == (4L..2L) as Any, "(2..1): Any == (4L..2L): Any")
|
||||
assertEquals(true, 'B'..'A' == 'W'..'B', "'B'..'A' == 'W'..'B'")
|
||||
assertEquals(false, (2..1) as Any == ('B'..'A') as Any, "(2..1): Any == ('B'..'A'): Any")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
var twoToFive = 2..5
|
||||
|
||||
if (twoToFive.contains(6)) return false;
|
||||
if (twoToFive.contains(1)) return false;
|
||||
if (twoToFive.contains(0)) return false;
|
||||
if (twoToFive.contains(-100)) return false;
|
||||
if (twoToFive.contains(10)) return false;
|
||||
if (!twoToFive.contains(2)) return false;
|
||||
if (!twoToFive.contains(3)) return false;
|
||||
if (!twoToFive.contains(4)) return false;
|
||||
if (!twoToFive.contains(5)) return false;
|
||||
if (!(twoToFive.start == 2)) return false;
|
||||
if (!(twoToFive.endInclusive == 5)) return false;
|
||||
|
||||
var sum = 0;
|
||||
for (i in twoToFive) {
|
||||
sum += i;
|
||||
}
|
||||
|
||||
if (sum != 14) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user