JS: add some tests to ensure that AST metadata is correctly serialized and deserialized and visible to JS optimizer

This commit is contained in:
Alexey Andreev
2017-02-28 17:57:27 +03:00
parent 80c1ac8b1b
commit 0058d2fdf6
4 changed files with 72 additions and 0 deletions
@@ -0,0 +1,14 @@
// FILE: a.kt
inline fun foo(f: (Int) -> String, x: Int = 23): String = "foo(${f(x)})"
// FILE: b.kt
// RECOMPILE
fun box(): String {
val result = foo({ it.toString() }) + foo({ it.toString() }, 42)
if (result != "foo(23)foo(42)") return "fail: $result"
return "OK"
}
@@ -0,0 +1,15 @@
// FILE: a.kt
package foo.bar
fun o() = "O"
// FILE: b.kt
package foo.bar
fun k() = "K"
// FILE: c.kt
// RECOMPILE
package foo.bar
fun box() = o() + k()
@@ -0,0 +1,25 @@
/// FILE: a.kt
fun a() = "["
fun b() = "]"
inline fun sideEffect(f: () -> String, g: () -> Unit): String {
g()
return f()
}
inline fun foo(f: () -> String, g: () -> Unit): String {
return a() + sideEffect(f, g) + b()
}
// FILE: b.kt
// RECOMPILE
fun box(): String {
val result = foo({ "*" }, { })
if (result != "[*]") return "fail: $result"
return "OK"
}