JS: add some tests to ensure that AST metadata is correctly serialized and deserialized and visible to JS optimizer
This commit is contained in:
@@ -3449,6 +3449,18 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArguments.kt")
|
||||
public void testDefaultArguments() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/defaultArguments.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("exportedPackage.kt")
|
||||
public void testExportedPackage() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/exportedPackage.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inline.kt")
|
||||
public void testInline() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/inline.kt");
|
||||
@@ -3460,6 +3472,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticStatement.kt")
|
||||
public void testSyntheticStatement() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/incremental/syntheticStatement.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/inheritance")
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user