JS: move more test to box tests
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
import bar.*
|
||||
|
||||
open class A() {
|
||||
open fun f() = 3;
|
||||
}
|
||||
|
||||
open class C() : B() {
|
||||
override fun f() = 5
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (A().f() != 3) return "fail1"
|
||||
if (B().f() != 4) return "fail2"
|
||||
if (C().f() != 5) return "fail3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package bar
|
||||
|
||||
import foo.A
|
||||
|
||||
open class B() : A() {
|
||||
override fun f() = 4
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
fun box() = (b.foo.A().tadada(b.foo.A()))
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
class A() {
|
||||
fun tadada(a: A) = "OK"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
import b.foo.*
|
||||
|
||||
fun box() = (A().tadada(A()))
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
class A() {
|
||||
fun tadada(a: A) = "OK"
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package bar
|
||||
|
||||
fun f() = 3;
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
import bar.*
|
||||
|
||||
fun box() = if (f() == 3) "OK" else "fail"
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
fun box() = b.bar.f()
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.bar
|
||||
|
||||
fun f() = "OK"
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package foo
|
||||
|
||||
val a = 2
|
||||
|
||||
fun box() = if ((a + bar.a) == 5) "OK" else "fail"
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package bar
|
||||
|
||||
val a = 3
|
||||
+28
-2
@@ -1,10 +1,36 @@
|
||||
// FILE: a.kt
|
||||
package bar
|
||||
|
||||
fun topLevelFun(s: String) = "topLevelFun: ${s}";
|
||||
|
||||
var topLevelVar = 100
|
||||
|
||||
val topLevelVal = 200
|
||||
|
||||
class A(val v: String) {
|
||||
fun memA(s: String) = "memA: ${v} ${s}"
|
||||
var propVar: Int = 1000
|
||||
val propVal: Int = 2000
|
||||
var text: String = "text"
|
||||
}
|
||||
|
||||
fun A.ext1(s: String): String = "A.ext1: ${this.v} ${s}"
|
||||
|
||||
var A.extProp: String
|
||||
get() = "${this.text}"
|
||||
set(value) {
|
||||
this.text = value
|
||||
}
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
import bar.*
|
||||
|
||||
fun A.ext2(s: String): String = "A.ext2: ${this.v} ${s}"
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
|
||||
assertEquals("topLevelFun: A", (::topLevelFun)("A"))
|
||||
assertEquals("A.ext1: test B", (A::ext1)(A("test"), "B"))
|
||||
@@ -25,5 +51,5 @@ fun box(): Boolean {
|
||||
(A::extProp).set(a, "new text")
|
||||
assertEquals("new text", (A::extProp).get(a))
|
||||
|
||||
return true
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
fun box() = if (b.foo.f() == 1) "OK" else "fail"
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
fun f() = 1
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: a.kt
|
||||
package a.foo
|
||||
|
||||
import b.foo.f
|
||||
|
||||
fun box() = if (f() == 1) "OK" else "fail"
|
||||
|
||||
|
||||
// FILE: b.kt
|
||||
package b.foo
|
||||
|
||||
fun f() = 1
|
||||
@@ -0,0 +1,20 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun eval() = 3
|
||||
fun eval(a: Int) = 4
|
||||
fun eval(a: String) = 5
|
||||
fun eval(a: String, b: Int) = 6
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (A().eval() != 3) return "fail1"
|
||||
if (A().eval(2) != 4) return "fail2"
|
||||
if (A().eval("3") != 5) return "fail3"
|
||||
if (A().eval("a", 3) != 6) return "fail4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
Vendored
+6
-6
@@ -7,19 +7,19 @@ class A(b: Int) {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
if (A(2).g() != 4) {
|
||||
return false;
|
||||
return "fail1"
|
||||
}
|
||||
if (A(3).m() != 2) {
|
||||
return false;
|
||||
return "fail2"
|
||||
}
|
||||
val a = A(100)
|
||||
if (a.g() != 200) {
|
||||
return false;
|
||||
return "fail3"
|
||||
}
|
||||
if (a.m() != 99) {
|
||||
return false;
|
||||
return "fail4"
|
||||
}
|
||||
return true;
|
||||
return "OK"
|
||||
}
|
||||
+5
-5
@@ -9,10 +9,10 @@ class A(val c: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
if (A.g != 3) return false
|
||||
if (A.c != "hoooray") return false
|
||||
if (A(2).c != 2) return false
|
||||
fun box(): String {
|
||||
if (A.g != 3) return "fail1"
|
||||
if (A.c != "hoooray") return "fail2"
|
||||
if (A(2).c != 2) return "fail3"
|
||||
|
||||
return true
|
||||
return "OK"
|
||||
}
|
||||
Vendored
Vendored
Vendored
+2
-2
@@ -14,6 +14,6 @@ fun Wow.dblSum(): Int {
|
||||
}
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
return (Wow().dblSum() == 6)
|
||||
fun box(): String {
|
||||
return if (Wow().dblSum() == 6) "OK" else "fail"
|
||||
}
|
||||
Vendored
Vendored
+2
-2
@@ -18,7 +18,7 @@ interface LastError {
|
||||
@native
|
||||
val chrome: Chrome = noImpl
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val lastError = chrome.extension.lastError?.message
|
||||
return lastError == null
|
||||
return if (lastError == null) "OK" else "fail"
|
||||
}
|
||||
Vendored
Vendored
+2
-2
@@ -7,7 +7,7 @@ val classes: Map<String, Any> = noImpl
|
||||
@native
|
||||
val classesMutable: HashMap<String, String> = noImpl
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
classesMutable.set("why", "?")
|
||||
return classes.get("answer") == 42 && classesMutable.get("why") == "?"
|
||||
return if (classes.get("answer") == 42 && classesMutable.get("why") == "?") "OK" else "fail"
|
||||
}
|
||||
Vendored
+2
-2
@@ -9,9 +9,9 @@ package foo
|
||||
|
||||
@library fun getResult() = false
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
a.f()
|
||||
a.f(2)
|
||||
return getResult()
|
||||
return if (getResult()) "OK" else "fail"
|
||||
}
|
||||
Vendored
Vendored
Vendored
Vendored
+1
-1
@@ -3,4 +3,4 @@ package foo
|
||||
@native
|
||||
fun returnFalse(): Boolean = noImpl
|
||||
|
||||
fun box() = !returnFalse()
|
||||
fun box() = if (!returnFalse()) "OK" else "fail"
|
||||
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
@native
|
||||
val c: Any? = noImpl
|
||||
|
||||
fun box(): String {
|
||||
if (c != null) return "fail1"
|
||||
return if (c == null) "OK" else "fail2"
|
||||
}
|
||||
Vendored
Vendored
Vendored
+5
-1
@@ -38,4 +38,8 @@ fun testByteConversions(c: Byte): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
fun box() = testShortConversions(3) && testByteConversions(3)
|
||||
fun box(): String {
|
||||
if (!testShortConversions(3)) return "fail: testShortConversions"
|
||||
if (!testByteConversions(3)) return "fail: testByteConversions"
|
||||
return "OK"
|
||||
}
|
||||
+10
-10
@@ -1,44 +1,44 @@
|
||||
package foo
|
||||
|
||||
fun box(): Any? {
|
||||
fun box(): String {
|
||||
if (3 / 4 != 0) {
|
||||
return "1"
|
||||
return "fail11"
|
||||
}
|
||||
if (-5 / 4 != -1) {
|
||||
return -5 / 4
|
||||
return "fail2"
|
||||
}
|
||||
if ((3.0 / 4.0 - 0.75) > 0.01) {
|
||||
return "3"
|
||||
return "fail3"
|
||||
}
|
||||
if ((-10.0 / 4.0 + 2.5) > 0.01) {
|
||||
return "4"
|
||||
return "fail44"
|
||||
}
|
||||
val i1: Int = 5
|
||||
val i2: Int = 2
|
||||
if (i1 / i2 != 2) {
|
||||
return "5"
|
||||
return "fail55"
|
||||
}
|
||||
val i3: Short = 5
|
||||
val i4: Short = 2
|
||||
if (i3 / i4 != 2) {
|
||||
return "6"
|
||||
return "fail6"
|
||||
}
|
||||
val i5: Byte = 5
|
||||
val i6: Byte = 2
|
||||
if (i5 / i6 != 2) {
|
||||
return "7"
|
||||
return "fail7"
|
||||
}
|
||||
|
||||
val f1: Double = 5.0
|
||||
val f2: Double = 2.0
|
||||
if ((f1 / f2 - 2.5) > 0.01) {
|
||||
return "8"
|
||||
return "fail8"
|
||||
}
|
||||
|
||||
val f3: Float = 5.0.toFloat()
|
||||
val f4: Float = 2.0.toFloat()
|
||||
if ((f3 / f4 - 2.5.toFloat()) > 0.01) {
|
||||
return "9"
|
||||
return "fail9"
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
+23
-22
@@ -1,72 +1,73 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val c: Double = 3.6
|
||||
if (c.toDouble() != 3.6) {
|
||||
return false
|
||||
return "fail1"
|
||||
}
|
||||
if (c.toFloat() != 3.6.toFloat()) {
|
||||
return false
|
||||
return "fail2"
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
return "fail3"
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
return "fail4"
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
return "fail5"
|
||||
}
|
||||
|
||||
val cn: Double = -3.6
|
||||
if (cn.toDouble() != -3.6) {
|
||||
return false
|
||||
return "fail6"
|
||||
}
|
||||
if (cn.toFloat() != -3.6.toFloat()) {
|
||||
return false
|
||||
return "fail7"
|
||||
}
|
||||
if (cn.toByte() != (-3).toByte()) {
|
||||
return false
|
||||
return "fail8"
|
||||
}
|
||||
if (cn.toInt() != -3) {
|
||||
return false
|
||||
return "fail9"
|
||||
}
|
||||
if (cn.toShort() != (-3).toShort()) {
|
||||
return false
|
||||
return "fail10"
|
||||
}
|
||||
|
||||
val f: Float = 3.6.toFloat()
|
||||
if (f.toDouble() != 3.6) {
|
||||
return false
|
||||
return "fail11"
|
||||
}
|
||||
if (f.toFloat() != 3.6.toFloat()) {
|
||||
return false
|
||||
return "fail12"
|
||||
}
|
||||
if (f.toByte() != 3.toByte()) {
|
||||
return false
|
||||
return "fail13"
|
||||
}
|
||||
if (f.toInt() != 3) {
|
||||
return false
|
||||
return "fail14"
|
||||
}
|
||||
if (f.toShort() != 3.toShort()) {
|
||||
return false
|
||||
return "fail15"
|
||||
}
|
||||
|
||||
val fn: Float = -3.6.toFloat()
|
||||
if (fn.toDouble() != -3.6) {
|
||||
return false
|
||||
return "fail16"
|
||||
}
|
||||
if (fn.toFloat() != -3.6.toFloat()) {
|
||||
return false
|
||||
return "fail17"
|
||||
}
|
||||
if (fn.toByte() != (-3).toByte()) {
|
||||
return false
|
||||
return "fail18"
|
||||
}
|
||||
if (fn.toInt() != -3) {
|
||||
return false
|
||||
return "fail19"
|
||||
}
|
||||
if (fn.toShort() != (-3).toShort()) {
|
||||
return false
|
||||
return "fail20"
|
||||
}
|
||||
return true
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val i = 0x80000000 + 0x8000000
|
||||
return true
|
||||
return "OK"
|
||||
}
|
||||
+9
-9
@@ -1,28 +1,28 @@
|
||||
package foo
|
||||
|
||||
fun box(): Boolean {
|
||||
fun box(): String {
|
||||
val c: Int = 3
|
||||
if (c.toDouble() != 3.0) {
|
||||
return false
|
||||
return "fail1"
|
||||
}
|
||||
if (c.toFloat() != 3.toFloat()) {
|
||||
return false
|
||||
return "fail2"
|
||||
}
|
||||
if (c.toByte() != 3.toByte()) {
|
||||
return false
|
||||
return "fail3"
|
||||
}
|
||||
if (c.toInt() != 3) {
|
||||
return false
|
||||
return "fail4"
|
||||
}
|
||||
if (c.toShort() != 3.toShort()) {
|
||||
return false
|
||||
return "fail5"
|
||||
}
|
||||
val c2: Int = -5
|
||||
if (c2.toShort() != (-5).toShort()) {
|
||||
return false
|
||||
return "fail6"
|
||||
}
|
||||
if (c2.toFloat() != -5.toFloat()) {
|
||||
return false
|
||||
return "fail7"
|
||||
}
|
||||
return true
|
||||
return "OK"
|
||||
}
|
||||
Vendored
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user