Chromium Code Reviews| Index: test/cctest/test-parsing.cc |
| diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
| index 2e5019fd13b6e8469ace2e37c5182c6f6bf42aaa..d3156252e72d90dd743f4e6a21d36e042588d692 100644 |
| --- a/test/cctest/test-parsing.cc |
| +++ b/test/cctest/test-parsing.cc |
| @@ -5578,33 +5578,104 @@ TEST(StrongForIn) { |
| } |
| -TEST(StrongSuperCalls) { |
| +TEST(StrongConstructorThis) { |
| const char* sloppy_context_data[][2] = {{"", ""}, {NULL}}; |
| const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}}; |
| const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}}; |
| - const char* data[] = { |
| + const char* error_data[] = { |
| + "class C { constructor() { this; } }", |
| + "class C { constructor() { this.a; } }", |
| + "class C { constructor() { this['a']; } }", |
| + "class C { constructor() { (this); } }", |
| + "class C { constructor() { this(); } }", |
| + // TODO(rossberg): arrow functions not handled yet. |
| + // "class C { constructor() { () => this; } }", |
| + "class C { constructor() { this.a = 0, 0; } }", |
| + "class C { constructor() { (this.a = 0); } }", |
| + // "class C { constructor() { (() => this.a = 0)(); } }", |
| + "class C { constructor() { { this.a = 0; } } }", |
| + "class C { constructor() { if (1) this.a = 0; } }", |
| + "class C { constructor() { label: this.a = 0; } }", |
| + NULL}; |
|
marja
2015/04/21 09:01:37
These cases would be relevant to add:
this.a = th
rossberg
2015/04/21 09:47:47
Done.
|
| + |
| + const char* success_data[] = { |
| + "class C { constructor() { this.a = 0; } }", |
| + "class C { constructor() { label: 0; this.a = 0; this.b = 6; } }", |
| + NULL}; |
| + |
| + static const ParserFlag always_flags[] = { |
| + kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, |
| + kAllowHarmonyArrowFunctions |
| + }; |
| + RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + |
| + RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strong_context_data, success_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| +} |
| + |
| + |
| +TEST(StrongConstructorSuper) { |
| + const char* sloppy_context_data[][2] = {{"", ""}, {NULL}}; |
| + const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}}; |
| + const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}}; |
| + |
| + const char* error_data[] = { |
| "class C extends Object { constructor() {} }", |
| + "class C extends Object { constructor() { super.a; } }", |
| + "class C extends Object { constructor() { super['a']; } }", |
| + "class C extends Object { constructor() { super.a = 0; } }", |
| + "class C extends Object { constructor() { (super.a); } }", |
| + // TODO(rossberg): arrow functions do not handle super yet. |
| + // "class C extends Object { constructor() { () => super.a; } }", |
| + "class C extends Object { constructor() { super(), 0; } }", |
| "class C extends Object { constructor() { (super()); } }", |
| - "class C extends Object { constructor() { (() => super())(); } }", |
| + // "class C extends Object { constructor() { (() => super())(); } }", |
| "class C extends Object { constructor() { { super(); } } }", |
| "class C extends Object { constructor() { if (1) super(); } }", |
| + "class C extends Object { constructor() { label: super(); } }", |
| "class C extends Object { constructor() { super(), super(); } }", |
| "class C extends Object { constructor() { super(); super(); } }", |
|
marja
2015/04/21 09:01:37
Nit: these 2 lines are the same.
rossberg
2015/04/21 09:47:47
No, "," vs ";" ;)
|
| "class C extends Object { constructor() { super(); (super()); } }", |
| "class C extends Object { constructor() { super(); { super() } } }", |
| + "class C extends Object { constructor() { this.a = 0, super(); } }", |
| + "class C extends Object { constructor() { this.a = 0; super(); } }", |
| + "class C extends Object { constructor() { super(this.a = 0); } }", |
|
marja
2015/04/21 09:01:37
How about
super().foo; ?
rossberg
2015/04/21 09:47:47
Done.
|
| + NULL}; |
| + |
| + const char* success_data[] = { |
| + "class C extends Object { constructor() { super(); } }", |
| + "class C extends Object { constructor() { l: 66; super(); } }", |
|
marja
2015/04/21 09:01:37
Hmm, why is label: super(); forbidden but label: 6
rossberg
2015/04/21 09:47:47
Because the former nests the super call into a lab
|
| + "class C extends Object { constructor() { super(3); this.x = 0; } }", |
| + "class C extends Object { constructor() { 3; super(3); this.x = 0; } }", |
| NULL}; |
| static const ParserFlag always_flags[] = { |
| kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals, |
| kAllowHarmonyArrowFunctions |
| }; |
| - RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags, |
| - arraysize(always_flags)); |
| - RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, |
| - arraysize(always_flags)); |
| - RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, |
| - arraysize(always_flags)); |
| + RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + |
| + RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strong_context_data, success_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| } |
| @@ -5613,24 +5684,45 @@ TEST(StrongConstructorReturns) { |
| const char* strict_context_data[][2] = {{"'use strict';", ""}, {NULL}}; |
| const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}}; |
| - const char* data[] = { |
| + const char* error_data[] = { |
| "class C extends Object { constructor() { super(); return {}; } }", |
| "class C extends Object { constructor() { super(); { return {}; } } }", |
| "class C extends Object { constructor() { super(); if (1) return {}; } }", |
| "class C extends Object { constructor() { return; super(); } }", |
| "class C extends Object { constructor() { { return; } super(); } }", |
| "class C extends Object { constructor() { if (0) return; super(); } }", |
| + "class C { constructor() { return; this.a = 0; } }", |
| + "class C { constructor() { { return; } this.a = 0; } }", |
| + "class C { constructor() { if (0) return; this.a = 0; } }", |
| + "class C { constructor() { this.a = 0; if (0) return; this.b = 0; } }", |
| + NULL}; |
| + |
| + const char* success_data[] = { |
| + "class C extends Object { constructor() { super(); return; } }", |
| + "class C extends Object { constructor() { super(); { return } } }", |
| + "class C extends Object { constructor() { super(); if (1) return; } }", |
| + "class C { constructor() { this.a = 0; return; } }", |
| + "class C { constructor() { this.a = 0; { return; } } }", |
| + "class C { constructor() { this.a = 0; if (0) return; 65; } }", |
| + "class C extends Array { constructor() { super(); this.a = 9; return } }", |
| NULL}; |
| static const ParserFlag always_flags[] = { |
| kAllowStrongMode, kAllowHarmonyClasses, kAllowHarmonyObjectLiterals |
| }; |
| - RunParserSyncTest(sloppy_context_data, data, kError, NULL, 0, always_flags, |
| - arraysize(always_flags)); |
| - RunParserSyncTest(strict_context_data, data, kSuccess, NULL, 0, always_flags, |
| - arraysize(always_flags)); |
| - RunParserSyncTest(strong_context_data, data, kError, NULL, 0, always_flags, |
| - arraysize(always_flags)); |
| + RunParserSyncTest(sloppy_context_data, error_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, error_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strong_context_data, error_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + |
| + RunParserSyncTest(sloppy_context_data, success_data, kError, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strict_context_data, success_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| + RunParserSyncTest(strong_context_data, success_data, kSuccess, NULL, 0, |
| + always_flags, arraysize(always_flags)); |
| } |