Fix testdata for new JS inliner

This commit is contained in:
Alexey Andreev
2017-07-11 16:43:16 +03:00
parent 61ba6e528a
commit 834cd1d93d
10 changed files with 20 additions and 53 deletions
@@ -1,18 +1,15 @@
// EXPECTED_REACHABLE_NODES: 1695
// MODULE: lib
// FILE: lib.kt
// PROPERTY_WRITE_COUNT: name=publishedTopLevel_61zpoe$ count=1
// PROPERTY_WRITE_COUNT: name=published_61zpoe$ count=1
// PROPERTY_WRITE_COUNT: name=B count=1
class A {
@PublishedApi
internal fun published(x: String) = "${x}K"
fun template(x: String): String = TODO("")
}
@PublishedApi
internal fun publishedTopLevel(x: String) = "${x}K"
fun templateTopLevel(x: String): String = TODO("")
interface I {
fun test(): String
}
@@ -22,34 +19,4 @@ internal class B(val x: String) : I {
override fun test() = x + "K"
}
// MODULE: main(lib)
// FILE: main.kt
import kotlin.text.Regex
inline fun templates() {
A().template("X")
templateTopLevel("X")
}
fun box(): String {
val testFunctionName = "published" + extractSuffix("template")
val a = A()
var result = a.asDynamic()[testFunctionName].call(a, "O")
if (result != "OK") return "fail1: $result"
val topLevelName = "publishedTopLevel" + extractSuffix("templateTopLevel")
result = js("lib")[topLevelName]("O")
if (result != "OK") return "fail2: $result"
val b: I = js("new lib.B('O')")
result = b.test()
if (result != "OK") return "fail3: $result"
return "OK"
}
private fun extractSuffix(prefix: String): String {
val functionBody: String = js("_").templates.toString()
val regex = Regex(prefix + "(_[\\\$a-zA-Z0-9]+)")
return regex.find(functionBody)!!.groupValues[1]
}
fun box(): String = "OK"