Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Unified Diff: test/cctest/test-parsing.cc

Issue 1024063002: [strong] checking of this & super in constructors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/classes.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 2e5019fd13b6e8469ace2e37c5182c6f6bf42aaa..bcea815d67b29bf2bff826ccd520dad047eb4228 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -5578,21 +5578,67 @@ 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[] = {
+ "class C extends Object { constructor() { this; } }",
+ "class C extends Object { constructor() { this.a; } }",
+ "class C extends Object { constructor() { this['a']; } }",
+ "class C extends Object { constructor() { this.a = 0; } }",
+ "class C extends Object { constructor() { (this); } }",
marja 2015/03/23 10:20:07 I'm not sure if this test is testing what it looks
rossberg 2015/04/20 17:21:11 Oops, yes, this test wasn't supposed to test missi
+ "class C extends Object { constructor() { this(); } }",
+ // TODO(rossberg): arrow functions not handled yet.
+ // "class C extends Object { constructor() { () => this; } }",
+ "class C extends Object { constructor() { this.a = 0, 0; } }",
+ "class C extends Object { constructor() { (this.a = 0); } }",
+ // "class C extends Object { constructor() { (() => this.a = 0)(); } }",
+ "class C extends Object { constructor() { { this.a = 0; } } }",
+ "class C extends Object { constructor() { if (1) this.a = 0; } }",
+ "class C extends Object { constructor() { label: this.a = 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));
+}
+
+
+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* 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(); } }",
"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); } }",
NULL};
static const ParserFlag always_flags[] = {
@@ -5620,6 +5666,9 @@ TEST(StrongConstructorReturns) {
"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 extends Object { constructor() { return; this.a = 0; } }",
+ "class C extends Object { constructor() { { return; } this.a = 0; } }",
+ "class C extends Object { constructor() { if (0) return; this.a = 0; } }",
NULL};
static const ParserFlag always_flags[] = {
« no previous file with comments | « src/preparser.cc ('k') | test/mjsunit/strong/classes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698