JS backend: added tests which pass an extension lambda to native code and visa versa.

Added workarounds in some tests because Rhino wrongly implicitly converts first parameter of `Function.call` to `Object`. But it's contradicts to ES5 specification(par. 15.3.4.4).

(#KT-4238, #KT-4345) In progress
This commit is contained in:
Zalim Bashorov
2014-03-12 20:56:42 +04:00
parent 597fff45e3
commit 206be96509
7 changed files with 92 additions and 18 deletions
@@ -1,15 +1,30 @@
package foo
fun assertEquals<T>(expected: T, actual: T, message: String) {
if (expected != actual) throw Exception("Failed when $message, expected = $expected, actual = $actual")
}
// workaround for Rhino
var n = 0
class A {
val i = ++n
}
fun box(): String {
fun Int.foo(): Boolean {
fun Int.bar() = this == 2 && this@foo == 1
val b = { this == 1 }
fun A.foo() {
fun A.bar() {
assertEquals(2, this.i, "check this.i in A.bar()")
assertEquals(1, this@foo.i, "check this@foo.i in A.bar()")
}
val b = { assertEquals(1, this.i, "check this.i in b") }
return this == 1 && 2.bar() && b()
}
assertEquals(1, this.i, "check this.i in A.foo()")
A().bar()
b()
}
if (!1.foo()) return "Failed"
A().foo()
return "OK"
return "OK"
}