当前位置: 首页>>代码示例>>Java>>正文


Java LanguageMode.ECMASCRIPT_NEXT属性代码示例

本文整理汇总了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("({...{...{}}})");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:11,代码来源:CodePrinterTest.java

示例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())");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:9,代码来源:CodePrinterTest.java

示例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(){}");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:9,代码来源:CodePrinterTest.java

示例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](){}}");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:9,代码来源:CodePrinterTest.java

示例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");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:CodePrinterTest.java

示例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("`\\``");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:28,代码来源:CodePrinterTest.java

示例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}");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:5,代码来源:CodePrinterTest.java

示例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");
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:6,代码来源:CodePrinterTest.java


注:本文中的com.google.javascript.jscomp.CompilerOptions.LanguageMode.ECMASCRIPT_NEXT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。