use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2021IntegrationTest method logicalAsssignmentsSimpleCastType_supportedWithTranspilation.
@Test
public void logicalAsssignmentsSimpleCastType_supportedWithTranspilation() {
CompilerOptions options = fullyOptimizedCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addExtra("let x").buildExternsFile("externs"));
test(options, "/** @type {?} */ (x) ||= 's'", "x || (x = 's')");
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2021IntegrationTest method logicalAssignmentSimpleTranspiledOutput3.
@Test
public void logicalAssignmentSimpleTranspiledOutput3() {
CompilerOptions options = fullyOptimizedCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addExtra("let w, x, y, z").buildExternsFile("externs"));
test(options, "w ||= (x &&= (y ??= z))", "w || (w = x && (x = y ?? (y = z)));");
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2021IntegrationTest method logicalAssignmentSimpleTranspiledOutputRHSNotExecuted.
@Test
public void logicalAssignmentSimpleTranspiledOutputRHSNotExecuted() {
CompilerOptions options = fullyOptimizedCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addConsole().buildExternsFile("externs.js"));
test(options, lines(//
"let n = null;", "n &&= foo();", "function foo() {", " console.log('should not be executed');", "}"), "");
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2021IntegrationTest method logicalAsssignmentsPropRefWithElementCastType_supportedOnlyWithoutTranspilation.
@Test
public void logicalAsssignmentsPropRefWithElementCastType_supportedOnlyWithoutTranspilation() {
CompilerOptions options = optimizedWithoutTranspilationCompilerOptions();
externs = ImmutableList.of(new TestExternsBuilder().addExtra("let foo, x").buildExternsFile("externs"));
test(options, "/** @type {number} */ (foo[x]) ??= 5", lines(//
"let a, b;", "(a = foo)[b = x] ?? (a[b] = 5)"));
}
use of com.google.javascript.jscomp.testing.TestExternsBuilder in project closure-compiler by google.
the class ES2022IntegrationTest method publicClassFields_supportedInOptimizationsMode1.
@Test
public void publicClassFields_supportedInOptimizationsMode1() {
CompilerOptions options = fullyOptimizedCompilerOptions();
options.setPrintSourceAfterEachPass(true);
externs = ImmutableList.of(new TestExternsBuilder().addConsole().buildExternsFile("externs"));
test(options, lines(//
"class MyClass {", " /** @type {number} */", " f1 = 2;", " /** @type {string} */", " f2 = 'hi';", " f3 = function() { return this.f1 };", " m1() { return this.f2; }", "}", "console.log(new MyClass().f1);", "console.log(new MyClass().f2);", "console.log(new MyClass().f3());", "console.log(new MyClass().m1());"), lines("console.log(2);", "console.log('hi');", "console.log(2);", "console.log('hi');"));
}
Aggregations