Add tests showing how cast nodes get printed.
@@ -261,6 +261,23 @@ public final class CodePrinterTest extends CodePrinterTestBase {
assertPrint("if(x){if(y){};;;}", "if(x)if(y);");
}
+ public void testPrintCast1() {
+ assertPrint("var x = /** @type {number} */ (0);", "var x=(0)");
+ assertPrettyPrintSame("var x = /** @type {number} */ (0);\n");
+ }
+
+ public void testPrintCast2() {
+ assertPrint("var x = (2+3) * 4;", "var x=(2+3)*4");
+ assertPrint("var x = /** @type {number} */ (2+3) * 4;", "var x=(2+3)*4");
+ assertPrettyPrintSame("var x = /** @type {number} */ (2 + 3) * 4;\n");
+ }
+
+ public void testPrintCast3() {
+ assertPrint("var x = (2*3) + 4;", "var x=2*3+4");
+ assertPrint("var x = /** @type {number} */ (2*3) + 4;", "var x=(2*3)+4");
+ assertPrettyPrintSame("var x = /** @type {number} */ (2 * 3) + 4;\n");
+ }
+
public void testLetConstInIf() {
languageMode = LanguageMode.ECMASCRIPT_NEXT;
assertPrint("if (true) { let x; };", "if(true){let x}");
