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

Side by Side Diff: test/cctest/test-parsing.cc

Issue 1409253007: Scope cleanup: remove unused bits and accessors (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/scopes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 { "function f() {", "}" }, 972 { "function f() {", "}" },
973 { "var f = () => {", "};" }, 973 { "var f = () => {", "};" },
974 { "class C { constructor() {", "} }" }, 974 { "class C { constructor() {", "} }" },
975 }; 975 };
976 976
977 enum Expected { 977 enum Expected {
978 NONE = 0, 978 NONE = 0,
979 ARGUMENTS = 1, 979 ARGUMENTS = 1,
980 SUPER_PROPERTY = 1 << 1, 980 SUPER_PROPERTY = 1 << 1,
981 THIS = 1 << 2, 981 THIS = 1 << 2,
982 INNER_ARGUMENTS = 1 << 3,
983 EVAL = 1 << 4 982 EVAL = 1 << 4
984 }; 983 };
985 984
986 // clang-format off 985 // clang-format off
987 static const struct { 986 static const struct {
988 const char* body; 987 const char* body;
989 int expected; 988 int expected;
990 } source_data[] = { 989 } source_data[] = {
991 {"", NONE}, 990 {"", NONE},
992 {"return this", THIS}, 991 {"return this", THIS},
(...skipping 21 matching lines...) Expand all
1014 {"return function (x) { return this + x }", NONE}, 1013 {"return function (x) { return this + x }", NONE},
1015 {"return { m(x) { return super.m() + x } }", NONE}, 1014 {"return { m(x) { return super.m() + x } }", NONE},
1016 {"var x = function () { this.foo = 42 };", NONE}, 1015 {"var x = function () { this.foo = 42 };", NONE},
1017 {"var x = { m() { super.foo = 42 } };", NONE}, 1016 {"var x = { m() { super.foo = 42 } };", NONE},
1018 {"if (1) { return function () { while (true) new this() } }", NONE}, 1017 {"if (1) { return function () { while (true) new this() } }", NONE},
1019 {"if (1) { return { m() { while (true) super.m() } } }", NONE}, 1018 {"if (1) { return { m() { while (true) super.m() } } }", NONE},
1020 {"return function (x) { return () => this }", NONE}, 1019 {"return function (x) { return () => this }", NONE},
1021 {"return { m(x) { return () => super.m() } }", NONE}, 1020 {"return { m(x) { return () => super.m() } }", NONE},
1022 // Flags must be correctly set when using block scoping. 1021 // Flags must be correctly set when using block scoping.
1023 {"\"use strict\"; while (true) { let x; this, arguments; }", 1022 {"\"use strict\"; while (true) { let x; this, arguments; }",
1024 INNER_ARGUMENTS | THIS}, 1023 THIS},
1025 {"\"use strict\"; while (true) { let x; this, super.f(), arguments; }", 1024 {"\"use strict\"; while (true) { let x; this, super.f(), arguments; }",
1026 INNER_ARGUMENTS | SUPER_PROPERTY | THIS}, 1025 SUPER_PROPERTY | THIS},
1027 {"\"use strict\"; if (foo()) { let x; this.f() }", THIS}, 1026 {"\"use strict\"; if (foo()) { let x; this.f() }", THIS},
1028 {"\"use strict\"; if (foo()) { let x; super.f() }", SUPER_PROPERTY}, 1027 {"\"use strict\"; if (foo()) { let x; super.f() }", SUPER_PROPERTY},
1029 {"\"use strict\"; if (1) {" 1028 {"\"use strict\"; if (1) {"
1030 " let x; return { m() { return this + super.m() + arguments } }" 1029 " let x; return { m() { return this + super.m() + arguments } }"
1031 "}", 1030 "}",
1032 NONE}, 1031 NONE},
1033 {"eval(42)", EVAL}, 1032 {"eval(42)", EVAL},
1034 {"if (1) { eval(42) }", EVAL}, 1033 {"if (1) { eval(42) }", EVAL},
1035 {"eval('super.x')", EVAL}, 1034 {"eval('super.x')", EVAL},
1036 {"eval('this.x')", EVAL}, 1035 {"eval('this.x')", EVAL},
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 } 1086 }
1088 CHECK_EQ((source_data[i].expected & ARGUMENTS) != 0, 1087 CHECK_EQ((source_data[i].expected & ARGUMENTS) != 0,
1089 scope->uses_arguments()); 1088 scope->uses_arguments());
1090 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0, 1089 CHECK_EQ((source_data[i].expected & SUPER_PROPERTY) != 0,
1091 scope->uses_super_property()); 1090 scope->uses_super_property());
1092 if ((source_data[i].expected & THIS) != 0) { 1091 if ((source_data[i].expected & THIS) != 0) {
1093 // Currently the is_used() flag is conservative; all variables in a 1092 // Currently the is_used() flag is conservative; all variables in a
1094 // script scope are marked as used. 1093 // script scope are marked as used.
1095 CHECK(scope->LookupThis()->is_used()); 1094 CHECK(scope->LookupThis()->is_used());
1096 } 1095 }
1097 CHECK_EQ((source_data[i].expected & INNER_ARGUMENTS) != 0,
1098 scope->inner_uses_arguments());
1099 CHECK_EQ((source_data[i].expected & EVAL) != 0, scope->calls_eval()); 1096 CHECK_EQ((source_data[i].expected & EVAL) != 0, scope->calls_eval());
1100 } 1097 }
1101 } 1098 }
1102 } 1099 }
1103 1100
1104 1101
1105 static void CheckParsesToNumber(const char* source, bool with_dot) { 1102 static void CheckParsesToNumber(const char* source, bool with_dot) {
1106 v8::V8::Initialize(); 1103 v8::V8::Initialize();
1107 HandleAndZoneScope handles; 1104 HandleAndZoneScope handles;
1108 1105
(...skipping 6142 matching lines...) Expand 10 before | Expand all | Expand 10 after
7251 NULL 7248 NULL
7252 }; 7249 };
7253 // clang-format on 7250 // clang-format on
7254 7251
7255 static const ParserFlag fail_flags[] = { 7252 static const ParserFlag fail_flags[] = {
7256 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst, 7253 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst,
7257 kAllowHarmonyDestructuring}; 7254 kAllowHarmonyDestructuring};
7258 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags, 7255 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags,
7259 arraysize(fail_flags)); 7256 arraysize(fail_flags));
7260 } 7257 }
OLDNEW
« no previous file with comments | « src/scopes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698