use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2022IntegrationTest method publicClassFields_supportedInChecksOnlyMode.
@Test
public void publicClassFields_supportedInChecksOnlyMode() {
CompilerOptions options = checksOnlyCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addConsole().buildExternsFile("externs"));
testNoWarnings(options, lines(//
"class MyClass {", " /** @type {number} */", " x = 2;", " y;", "}", "console.log(new MyClass().x);"));
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2022IntegrationTest method computedPublicClassFields_supportedInChecksOnlyMode2.
@Test
public void computedPublicClassFields_supportedInChecksOnlyMode2() {
CompilerOptions options = checksOnlyCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addConsole().buildExternsFile("externs"));
testNoWarnings(options, lines(//
"/** @dict */", "class MyClass {", " ['x'] = 5;", "}", "console.log(new MyClass()['x']);"));
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2022IntegrationTest method publicClassFields_supportedInChecksOnlyMode2.
@Test
public void publicClassFields_supportedInChecksOnlyMode2() {
CompilerOptions options = checksOnlyCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addConsole().buildExternsFile("externs"));
testNoWarnings(options, lines(//
"class MyClass {", " x = '';", " y;", "}", "console.log(new MyClass().x);"));
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class AdvancedOptimizationsIntegrationTest method testModififyingDestructuringParamWithoutTranspilation.
@Test
public void testModififyingDestructuringParamWithoutTranspilation() {
CompilerOptions options = createCompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
options.setLanguageOut(LanguageMode.ECMASCRIPT_2015);
externs = ImmutableList.of(SourceFile.fromCode("testExterns.js", new TestExternsBuilder().addAlert().build()));
test(options, lines("function installBaa({ obj }) {", " obj.baa = 'foo';", "}", "", "const obj = {};", "installBaa({ obj });", "alert(obj.baa);"), lines(//
"const a = {};", "(function({b}){", " b.a = 'foo';", "})({b: a});", "alert(a.a);"));
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class AdvancedOptimizationsIntegrationTest method nullishCoalesceChainTranspiledOutput.
@Test
public void nullishCoalesceChainTranspiledOutput() {
CompilerOptions options = createCompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
options.setLanguageIn(LanguageMode.ECMASCRIPT_NEXT_IN);
options.setLanguageOut(LanguageMode.ECMASCRIPT_2019);
externs = ImmutableList.of(new TestExternsBuilder().addExtra("var x, y, z").buildExternsFile("externs"));
test(options, "x ?? y ?? z", "let a, b; null != (b = null != (a = x) ? a : y) ? b : z");
}
Aggregations