Skip to content

Commit

Permalink
RemoveUnusedCodeClassPropertiesTest Clean up some ES6-specific test c…
Browse files Browse the repository at this point in the history
…ases

Re-enabled with some tweaking necessary test cases that should pass with
the features that are currently implemented.
Deleted a couple that were not testing anything useful.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179980475
  • Loading branch information
brad4d authored and blickly committed Jan 2, 2018
1 parent 4ad9784 commit 7ac76ab
Showing 1 changed file with 41 additions and 46 deletions.
Expand Up @@ -398,22 +398,25 @@ public void disabledTestObjectDefineProperties_used_setter_removed() {
} }


// TODO(b/66971163): make this pass // TODO(b/66971163): make this pass
public void disabledTestEs6GettersWithoutTranspilation() { public void testEs6GettersWithoutTranspilation() {
test("class C { get value() { return 0; } }", "class C {}"); test(
"class C { get value() { return 0; } }", // preserve newline
"class C { }");
testSame("class C { get value() { return 0; } } const x = (new C()).value"); testSame("class C { get value() { return 0; } } const x = (new C()).value");
} }


public void testES6ClassComputedProperty() { public void testES6ClassComputedProperty() {
testSame("class C { ['test' + 3]() { return 0; } }"); testSame("class C { ['test' + 3]() { return 0; } }");
} }


// TODO(b/66971163): make this pass public void testEs6SettersWithoutTranspilation() {
public void disabledTestEs6SettersWithoutTranspilation() { test(
test("class C { set value(val) { this.internalVal = val; } }", "class C {}"); "class C { set value(val) { this.internalVal = val; } }", // preserve newline
"class C { }");


test( test(
"class C { set value(val) { this.internalVal = val; } } (new C()).value = 3;", "class C { set value(val) { this.internalVal = val; } } (new C()).value = 3;",
"class C { set value(val) { val; } } (new C()).value = 3;"); "class C { set value(val) { } } (new C()).value = 3;");
testSame( testSame(
lines( lines(
"class C {", "class C {",
Expand Down Expand Up @@ -514,45 +517,37 @@ public void disabledTestEs6SettersRemoval() {
"$jscomp.global.Object.defineProperties(C.prototype, {});")); "$jscomp.global.Object.defineProperties(C.prototype, {});"));
} }


// TODO(b/66971163): make this pass public void testEs6ArrowFunction() {
public void disabledTestEs6ArrowFunction() { test(
test("() => this.a = 1", "() => 1"); "const arrow = () => this.a = 1;", // preserve newline
testSame("() => ({a: 2})"); "const arrow = () => 1;");
testSame("() => {y.a = 2; this.a = 2;}"); testSame("const arrow = () => ({a: 2})");
testSame("var y = {}; const arrow = () => {y.a = 2; this.a = 2;}");
test( test(
lines( lines(
"var A = () => {this.foo = 1;}", "function A() {",
" this.foo = 1;",
"}",
"A.prototype.foo = 0;", "A.prototype.foo = 0;",
"A.prototype.method = () => {this.foo++};", "A.prototype.getIncr = function() {",
"new A().method()"), " return () => { this.foo++; };",
"};",
"new A().getIncr()"),
lines( lines(
"var A = () => {1;}", "function A() {",
"0;", " ",
"A.prototype.method = () => {0;};", "}",
"new A().method()")); " ",
} "A.prototype.getIncr = function() {",

" return () => { };",
// TODO(b/66971163): make this pass "};",
public void disabledTestEs6ForOf() { "new A().getIncr()"));
test("this.y = 1;for (var a of x) { alert(x[a]) }", "1; for (var a of x) { alert(x[a]) }");
testSame("var obj = {}; obj.a = 1; for (var a of obj) { alert(obj[a]) }");
testSame("this.y = {};for (var a of this.y) { alert(this.y[a]) }");
} }


// TODO(b/66971163): make this pass public void testEs6Generator() {
public void disabledTestEs6TemplateLiterals() {
test( test(
lines( "function* gen() { yield this.a = 1; }", // preserve newline
"function tag(strings, x) { this.a = x; }", "function* gen() { yield 1; }");
"tag`tag ${0} function`"),
lines(
"function tag(strings, x) { x; }",
"tag`tag ${0} function`"));
}

// TODO(b/66971163): make this pass
public void disabledTestEs6Generator() {
test("function* gen() { yield this.a = 1; }", "function* gen() { yield 1; }");
testSame("function* gen() { yield this.a = 1; yield this.a; }"); testSame("function* gen() { yield this.a = 1; yield this.a; }");
} }


Expand Down Expand Up @@ -674,23 +669,23 @@ public void disabledTestEs6Destructuring() {
test("({['a']:0}); this.a = 1;", "({['a']:0}); 1;"); test("({['a']:0}); this.a = 1;", "({['a']:0}); 1;");
} }


// TODO(b/66971163): make this pass public void testEs6DefaultParameter() {
public void disabledTestEs6DefaultParameter() { test(
test("function foo(x, y = this.a = 1) {}", "function foo(x, y = 1) {}"); "function foo(x, y = this.a = 1) {}", // preserve newline
"function foo(x, y = 1) {}");
testSame("this.a = 1; function foo(x, y = this.a) {}"); testSame("this.a = 1; function foo(x, y = this.a) {}");
} }


// TODO(b/66971163): make this pass public void testEs8AsyncFunction() {
public void disabledTestEs8AsyncFunction() {
test( test(
lines( lines(
"async function foo(promise) {", "async function foo(promise) {", // preserve newlines
" this.x = 1;", " this.x = 1;",
" return await promise;", " return await promise;",
"}"), "}"),
lines( lines(
"async function foo(promise) {", "async function foo(promise) {", // preserve newlines
" 1;", " ",
" return await promise;", " return await promise;",
"}")); "}"));


Expand Down

0 comments on commit 7ac76ab

Please sign in to comment.