Add simple tests for interop with native code.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package foo
|
||||
|
||||
import js.*
|
||||
|
||||
native
|
||||
class A(b : Int) {
|
||||
fun g() : Int = js.noImpl
|
||||
fun m() : Int = js.noImpl
|
||||
}
|
||||
|
||||
|
||||
fun box() : Boolean {
|
||||
if (A(2).g() != 4) {
|
||||
return false;
|
||||
}
|
||||
if (A(3).m() != 2) {
|
||||
return false;
|
||||
}
|
||||
val a = A(100)
|
||||
if (a.g() != 200) {
|
||||
return false;
|
||||
}
|
||||
if (a.m() != 99) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package foo
|
||||
|
||||
import js.*
|
||||
|
||||
native
|
||||
fun returnFalse() : Boolean = js.noImpl
|
||||
|
||||
fun box() = !returnFalse()
|
||||
@@ -0,0 +1,22 @@
|
||||
package foo
|
||||
|
||||
import js.*
|
||||
|
||||
/*function g should return 0 if a parameter is undefined 1 if parameter is 1 and 3 if parameter is 3*/
|
||||
native
|
||||
fun f(g : (Int?)-> Int) : Boolean = js.noImpl
|
||||
|
||||
|
||||
fun box() : Boolean {
|
||||
val b = {
|
||||
(a : Int?) ->
|
||||
if (a == null) {
|
||||
0
|
||||
} else if (a == 1) {
|
||||
1
|
||||
} else {
|
||||
3
|
||||
}
|
||||
}
|
||||
return f(b)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package foo
|
||||
|
||||
import js.*
|
||||
|
||||
native
|
||||
fun paramCount(vararg a : Int) : Int = js.noImpl
|
||||
|
||||
fun count(vararg a : Int) = a.size
|
||||
|
||||
fun box() : Boolean {
|
||||
if (paramCount(1, 2 ,3) != 3) {
|
||||
return false;
|
||||
}
|
||||
if (paramCount() != 0) {
|
||||
return false;
|
||||
}
|
||||
if (count() != 0) {
|
||||
return false;
|
||||
}
|
||||
if (count(1, 1, 1, 1) != 4) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user