本文整理汇总了Java中com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT_NEXT属性的典型用法代码示例。如果您正苦于以下问题:Java LanguageMode.ECMASCRIPT_NEXT属性的具体用法?Java LanguageMode.ECMASCRIPT_NEXT怎么用?Java LanguageMode.ECMASCRIPT_NEXT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.javascript.jscomp.CompilerOptions.LanguageMode
的用法示例。
在下文中一共展示了LanguageMode.ECMASCRIPT_NEXT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testObjectLiteralWithSpread
public void testObjectLiteralWithSpread() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("({...{}})");
assertPrintSame("({...x})");
assertPrintSame("({...x,a:1})");
assertPrintSame("({a:1,...x})");
assertPrintSame("({a:1,...x,b:1})");
assertPrintSame("({...x,...y})");
assertPrintSame("({...x,...f()})");
assertPrintSame("({...{...{}}})");
}
示例2: testPrintObjectPatternWithRest
public void testPrintObjectPatternWithRest() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("const {a,...rest}=foo()");
assertPrintSame("var {a,...rest}=foo()");
assertPrintSame("let {a,...rest}=foo()");
assertPrintSame("({a,...rest}=foo())");
assertPrintSame("({a=2,...rest}=foo())");
assertPrintSame("({a:b=2,...rest}=foo())");
}
示例3: testAsyncFunction
public void testAsyncFunction() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("async function f(){}");
assertPrintSame("let f=async function f(){}");
assertPrintSame("let f=async function(){}");
// implicit semicolon prevents async being treated as a keyword
assertPrint("async\nfunction f(){}", "async;function f(){}");
assertPrint("let f=async\nfunction f(){}", "let f=async;function f(){}");
}
示例4: testAsyncMethod
public void testAsyncMethod() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("o={async m(){}}");
assertPrintSame("o={async[a+b](){}}");
assertPrintSame("class C{async m(){}}");
assertPrintSame("class C{async[a+b](){}}");
assertPrintSame("class C{static async m(){}}");
assertPrintSame("class C{static async[a+b](){}}");
}
示例5: testAwaitExpression
public void testAwaitExpression() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("async function f(promise){return await promise}");
assertPrintSame("pwait=async function(promise){return await promise}");
assertPrintSame("class C{async pwait(promise){await promise}}");
assertPrintSame("o={async pwait(promise){await promise}}");
assertPrintSame("pwait=async(promise)=>await promise");
}
示例6: testTemplateLiteral
public void testTemplateLiteral() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("`hello`");
assertPrintSame("`\\\\bhello`");
assertPrint("`hel\rlo`", "`hel\\nlo`");
assertPrint("`hel\r\nlo`", "`hel\\nlo`");
assertPrint("`hello`\n'world'", "`hello`;\"world\"");
assertPrint("`hello`\n`world`", "`hello``world`");
assertPrint("var x=`TestA`\n`TemplateB`", "var x=`TestA``TemplateB`");
assertPrintSame("`hello``world`");
assertPrintSame("`hello${world}!`");
assertPrintSame("`hello${world} ${name}!`");
assertPrintSame("`hello${(function(){let x=3})()}`");
assertPrintSame("(function(){})()`${(function(){})()}`");
assertPrintSame("url`hello`");
assertPrintSame("url(`hello`)");
assertPrint("`\\u{2026}`", "`\\u2026`");
assertPrint("`start\\u{2026}end`", "`start\\u2026end`");
assertPrint("`\\u{1f42a}`", "`\\ud83d\\udc2a`");
assertPrint("`start\\u{1f42a}end`", "`start\\ud83d\\udc2aend`");
assertPrintSame("`\\u2026`");
assertPrintSame("`start\\u2026end`");
assertPrintSame("`\"`");
assertPrintSame("`'`");
assertPrintSame("`\\``");
}
示例7: testLetConstInIf
public void testLetConstInIf() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrint("if (true) { let x; };", "if(true){let x}");
assertPrint("if (true) { const x = 0; };", "if(true){const x=0}");
}
示例8: testAsyncArrowFunction
public void testAsyncArrowFunction() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrintSame("async()=>1");
// implicit semicolon prevents async being treated as a keyword
assertPrint("f=async\n()=>1", "f=async;()=>1");
}