rra/ilgonmic/js-fun-import
[JS IR] Test import.meta syntax [JS IR] Add possibility to use import.meta [JS IR] Check if import function-like returns Promise [JS IR] Add test with import function syntax [JS IR] Allow import function-like in js function Merge-request: KT-MR-5948 Merged-by: Ilya Goncharov <Ilya.Goncharov@jetbrains.com> ^KT-51125 fixed
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
* Copyright (C) 1997-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Contributor(s):
|
||||
* Mike Ang
|
||||
* Mike McCabe
|
||||
*
|
||||
@@ -1140,6 +1140,13 @@ public class Parser {
|
||||
mustMatchToken(ts, TokenStream.GWT, "msg.no.paren");
|
||||
return pn;
|
||||
|
||||
case TokenStream.IMPORT:
|
||||
// for import() and import.meta syntax
|
||||
if (ts.peekToken() != TokenStream.LP && ts.peekToken() != TokenStream.DOT) {
|
||||
reportError(ts, "msg.syntax");
|
||||
}
|
||||
return nf.createName(TokenStream.tokenToName(TokenStream.IMPORT), position);
|
||||
|
||||
case TokenStream.NAME:
|
||||
String name = ts.getString();
|
||||
return nf.createName(name, position);
|
||||
|
||||
+6
@@ -2321,6 +2321,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/native"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importFunctionSyntax.kt")
|
||||
public void testImportFunctionSyntax() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/native/importFunctionSyntax.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("inheritanceInNativeClass.kt")
|
||||
public void testInheritanceInNativeClass() throws Exception {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// ES_MODULES
|
||||
|
||||
fun box(): String {
|
||||
if (js("import('hello')") !is kotlin.js.Promise<*>) return "fail1"
|
||||
if (!js("import.meta").url) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user