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

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

Issue 883823002: Implement proper scoping for "this" in arrow functions Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mjsunit/debug-scopes: Skip "this" the same as "arguments" Created 5 years, 10 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
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index ccd06e1ffd230b3ecb148c7e4f137a83477a2859..ad26f5c15ca71cf47a8de6815d734a7febeeec5f 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -920,7 +920,7 @@ static int Utf8LengthHelper(const char* s) {
}
-TEST(ScopeUsesArgumentsSuperThis) {
+TEST(ScopeUsesArgumentsSuper) {
static const struct {
const char* prefix;
const char* suffix;
@@ -934,11 +934,9 @@ TEST(ScopeUsesArgumentsSuperThis) {
ARGUMENTS = 1,
SUPER_PROPERTY = 2,
SUPER_CONSTRUCTOR_CALL = 4,
- THIS = 8,
- INNER_ARGUMENTS = 16,
- INNER_SUPER_PROPERTY = 32,
- INNER_SUPER_CONSTRUCTOR_CALL = 64,
- INNER_THIS = 128
+ INNER_ARGUMENTS = 8,
+ INNER_SUPER_PROPERTY = 16,
+ INNER_SUPER_CONSTRUCTOR_CALL = 32,
};
static const struct {
@@ -946,33 +944,30 @@ TEST(ScopeUsesArgumentsSuperThis) {
int expected;
} source_data[] = {
{"", NONE},
- {"return this", THIS},
{"return arguments", ARGUMENTS},
{"return super()", SUPER_CONSTRUCTOR_CALL},
{"return super.x", SUPER_PROPERTY},
{"return arguments[0]", ARGUMENTS},
- {"return this + arguments[0]", ARGUMENTS | THIS},
+ {"return this + arguments[0]", ARGUMENTS },
{"return this + arguments[0] + super.x",
- ARGUMENTS | SUPER_PROPERTY | THIS},
- {"return x => this + x", INNER_THIS},
+ ARGUMENTS | SUPER_PROPERTY },
+ {"return x => this + x", NONE},
{"return x => super() + x", INNER_SUPER_CONSTRUCTOR_CALL},
- {"this.foo = 42;", THIS},
- {"this.foo();", THIS},
- {"if (foo()) { this.f() }", THIS},
+ {"this.foo = 42;", NONE},
+ {"this.foo();", NONE},
+ {"if (foo()) { this.f() }", NONE},
{"if (foo()) { super.f() }", SUPER_PROPERTY},
- {"if (arguments.length) { this.f() }", ARGUMENTS | THIS},
- {"while (true) { this.f() }", THIS},
+ {"if (arguments.length) { this.f() }", ARGUMENTS},
+ {"while (true) { this.f() }", NONE},
{"while (true) { super.f() }", SUPER_PROPERTY},
- {"if (true) { while (true) this.foo(arguments) }", ARGUMENTS | THIS},
+ {"if (true) { while (true) this.foo(arguments) }", ARGUMENTS},
// Multiple nesting levels must work as well.
- {"while (true) { while (true) { while (true) return this } }", THIS},
+ {"while (true) { while (true) { while (true) return this } }", NONE},
{"while (true) { while (true) { while (true) return super() } }",
SUPER_CONSTRUCTOR_CALL},
- {"if (1) { return () => { while (true) new this() } }", INNER_THIS},
+ {"if (1) { return () => { while (true) new this() } }", NONE},
{"if (1) { return () => { while (true) new super() } }", NONE},
{"if (1) { return () => { while (true) new new super() } }", NONE},
- // Note that propagation of the inner_uses_this() value does not
- // cross boundaries of normal functions onto parent scopes.
{"return function (x) { return this + x }", NONE},
{"return function (x) { return super() + x }", NONE},
{"var x = function () { this.foo = 42 };", NONE},
@@ -983,10 +978,10 @@ TEST(ScopeUsesArgumentsSuperThis) {
{"return function (x) { return () => super() }", NONE},
// Flags must be correctly set when using block scoping.
{"\"use strict\"; while (true) { let x; this, arguments; }",
- INNER_ARGUMENTS | INNER_THIS},
+ INNER_ARGUMENTS},
{"\"use strict\"; while (true) { let x; this, super(), arguments; }",
- INNER_ARGUMENTS | INNER_SUPER_CONSTRUCTOR_CALL | INNER_THIS},
- {"\"use strict\"; if (foo()) { let x; this.f() }", INNER_THIS},
+ INNER_ARGUMENTS | INNER_SUPER_CONSTRUCTOR_CALL},
+ {"\"use strict\"; if (foo()) { let x; this.f() }", NONE},
{"\"use strict\"; if (foo()) { let x; super.f() }",
INNER_SUPER_PROPERTY},
{"\"use strict\"; if (1) {"
@@ -1042,15 +1037,12 @@ TEST(ScopeUsesArgumentsSuperThis) {
scope->uses_super_property());
CHECK_EQ((source_data[i].expected & SUPER_CONSTRUCTOR_CALL) != 0,
scope->uses_super_constructor_call());
- CHECK_EQ((source_data[i].expected & THIS) != 0, scope->uses_this());
CHECK_EQ((source_data[i].expected & INNER_ARGUMENTS) != 0,
scope->inner_uses_arguments());
CHECK_EQ((source_data[i].expected & INNER_SUPER_PROPERTY) != 0,
scope->inner_uses_super_property());
CHECK_EQ((source_data[i].expected & INNER_SUPER_CONSTRUCTOR_CALL) != 0,
scope->inner_uses_super_constructor_call());
- CHECK_EQ((source_data[i].expected & INNER_THIS) != 0,
- scope->inner_uses_this());
}
}
}
« src/scopes.h ('K') | « src/x64/lithium-codegen-x64.cc ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698