JS: create new common directory for all generated tests, migrate several tests there

This commit is contained in:
Alexey Andreev
2016-08-26 16:44:48 +03:00
parent 34a57f863b
commit 2bf0199959
321 changed files with 2123 additions and 2001 deletions
@@ -0,0 +1,57 @@
package foo
// HACKS
@native
const val ROOT = "Kotlin.modules.JS_TESTS"
@native
const val PATH_TO_F_CREATOR = "foo.B.far\$f"
@native
const val PATH_TO_G_CREATOR = "foo.B.gar\$f"
@native("$ROOT.$PATH_TO_F_CREATOR")
val F_CREATOR: Any = noImpl
@native("$ROOT.$PATH_TO_G_CREATOR")
val G_CREATOR: Any = noImpl
// Test
open class A {
fun foo() = "A::foo"
}
class B : A() {
fun boo() = "B::boo"
val far = { foo() }
val gar = { boo() }
}
fun box(): String {
val b = B()
val f = b.far
val g = b.gar
assertEquals("A::foo", f())
assertEquals("B::boo", g())
val fs = F_CREATOR.toString()
val gs = G_CREATOR.toString().replaceAll("boo", "foo")
assertEquals(gs, fs)
return "OK"
}
// Helpers
@native
fun String.replace(regexp: RegExp, replacement: String): String = noImpl
fun String.replaceAll(regexp: String, replacement: String): String = replace(RegExp(regexp, "g"), replacement)
@native
class RegExp(regexp: String, flags: String)