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

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

Issue 1773653002: [strong] Remove all remainders of strong mode (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Oversight Created 4 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 | « test/cctest/test-api.cc ('k') | test/mjsunit/es6/classes-subclass-builtins.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 fb18acedaad6e9432aa3a176e9c45bbebe987ca6..7a203d423817345bb5d15b6f7bc4101780861ec3 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1509,7 +1509,6 @@ enum ParserFlag {
kAllowHarmonyDestructuring,
kAllowHarmonyDestructuringAssignment,
kAllowHarmonyNewTarget,
- kAllowStrongMode,
kNoLegacyConst,
kAllowHarmonyFunctionSent,
kAllowHarmonyRestrictiveDeclarations,
@@ -1534,7 +1533,6 @@ void SetParserFlags(i::ParserBase<Traits>* parser,
flags.Contains(kAllowHarmonyDestructuring));
parser->set_allow_harmony_destructuring_assignment(
flags.Contains(kAllowHarmonyDestructuringAssignment));
- parser->set_allow_strong_mode(flags.Contains(kAllowStrongMode));
parser->set_allow_legacy_const(!flags.Contains(kNoLegacyConst));
parser->set_allow_harmony_function_sent(
flags.Contains(kAllowHarmonyFunctionSent));
@@ -1929,9 +1927,7 @@ TEST(ErrorsEvalAndArguments) {
// isn't.
const char* context_data[][2] = {
{"\"use strict\";", ""},
- {"\"use strong\";", ""},
{"var eval; function test_func() {\"use strict\"; ", "}"},
- {"var eval; function test_func() {\"use strong\"; ", "}"},
{NULL, NULL}};
const char* statement_data[] = {
@@ -1962,9 +1958,7 @@ TEST(ErrorsEvalAndArguments) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kError);
}
@@ -2071,8 +2065,6 @@ TEST(ErrorsFutureStrictReservedWords) {
const char* context_data[][2] = {
{"function test_func() {\"use strict\"; ", "}"},
{"() => { \"use strict\"; ", "}"},
- {"function test_func() {\"use strong\"; ", "}"},
- {"() => { \"use strong\"; ", "}"},
{NULL, NULL}};
const char* statement_data[] {
@@ -2080,11 +2072,7 @@ TEST(ErrorsFutureStrictReservedWords) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kError);
}
@@ -2261,13 +2249,6 @@ TEST(ErrorsYieldStrict) {
{"\"use strict\"; (function not_gen() {", "})"},
{"\"use strict\"; (function * gen() { (function not_gen() {", "}) })"},
{"() => {\"use strict\"; ", "}"},
- {"\"use strong\";", ""},
- {"\"use strong\"; function not_gen() {", "}"},
- {"function test_func() {\"use strong\"; ", "}"},
- {"\"use strong\"; function * gen() { function not_gen() {", "} }"},
- {"\"use strong\"; (function not_gen() {", "})"},
- {"\"use strong\"; (function * gen() { (function not_gen() {", "}) })"},
- {"() => {\"use strong\"; ", "}"},
{NULL, NULL}};
const char* statement_data[] = {
@@ -2288,9 +2269,7 @@ TEST(ErrorsYieldStrict) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kError);
}
@@ -2444,10 +2423,8 @@ TEST(ErrorsNameOfStrictFunction) {
const char* context_data[][2] = {
{ "function ", ""},
{ "\"use strict\"; function", ""},
- { "\"use strong\"; function", ""},
{ "function * ", ""},
{ "\"use strict\"; function * ", ""},
- { "\"use strong\"; function * ", ""},
{ NULL, NULL }
};
@@ -2462,9 +2439,7 @@ TEST(ErrorsNameOfStrictFunction) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kError);
}
@@ -2528,9 +2503,6 @@ TEST(ErrorsIllegalWordsAsLabelsStrict) {
{"\"use strict\";", ""},
{"function test_func() {\"use strict\"; ", "}"},
{"() => {\"use strict\"; ", "}"},
- {"\"use strong\";", ""},
- {"function test_func() {\"use strong\"; ", "}"},
- {"() => {\"use strong\"; ", "}"},
{NULL, NULL}};
#define LABELLED_WHILE(NAME) #NAME ": while (true) { break " #NAME "; }",
@@ -2541,9 +2513,7 @@ TEST(ErrorsIllegalWordsAsLabelsStrict) {
};
#undef LABELLED_WHILE
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kError);
}
@@ -2616,13 +2586,10 @@ TEST(NoErrorsParenthesizedDirectivePrologue) {
const char* statement_data[] = {
"(\"use strict\"); var eval;",
- "(\"use strong\"); var eval;",
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kSuccess);
}
@@ -2750,7 +2717,6 @@ TEST(FunctionDeclaresItselfStrict) {
const char* strict_statement_data[] = {
"\"use strict\";",
- "\"use strong\";",
NULL
};
@@ -2759,11 +2725,8 @@ TEST(FunctionDeclaresItselfStrict) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, strict_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(context_data, non_strict_statement_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(context_data, strict_statement_data, kError);
+ RunParserSyncTest(context_data, non_strict_statement_data, kSuccess);
}
@@ -3031,11 +2994,6 @@ TEST(TooManyArguments) {
TEST(StrictDelete) {
// "delete <Identifier>" is not allowed in strict mode.
- const char* strong_context_data[][2] = {
- {"\"use strong\"; ", ""},
- { NULL, NULL }
- };
-
const char* strict_context_data[][2] = {
{"\"use strict\"; ", ""},
{ NULL, NULL }
@@ -3077,27 +3035,14 @@ TEST(StrictDelete) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(strong_context_data, sloppy_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strict_context_data, sloppy_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess, NULL,
- 0, always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_context_data, sloppy_statement_data, kError);
+ RunParserSyncTest(sloppy_context_data, sloppy_statement_data, kSuccess);
- RunParserSyncTest(strong_context_data, good_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strict_context_data, good_statement_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_context_data, good_statement_data, kSuccess);
+ RunParserSyncTest(sloppy_context_data, good_statement_data, kSuccess);
- RunParserSyncTest(strong_context_data, bad_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strict_context_data, bad_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(sloppy_context_data, bad_statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_context_data, bad_statement_data, kError);
+ RunParserSyncTest(sloppy_context_data, bad_statement_data, kError);
}
@@ -3925,15 +3870,6 @@ TEST(NoErrorsArrowFunctions) {
TEST(ArrowFunctionsSloppyParameterNames) {
- const char* strong_context_data[][2] = {
- {"'use strong'; ", ";"},
- {"'use strong'; bar ? (", ") : baz;"},
- {"'use strong'; bar ? baz : (", ");"},
- {"'use strong'; bar, ", ";"},
- {"'use strong'; ", ", bar;"},
- {NULL, NULL}
- };
-
const char* strict_context_data[][2] = {
{"'use strict'; ", ";"},
{"'use strict'; bar ? (", ") : baz;"},
@@ -3973,13 +3909,8 @@ TEST(ArrowFunctionsSloppyParameterNames) {
NULL
};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(strong_context_data, statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strict_context_data, statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(sloppy_context_data, statement_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_context_data, statement_data, kError);
+ RunParserSyncTest(sloppy_context_data, statement_data, kSuccess);
}
@@ -3990,13 +3921,11 @@ TEST(ArrowFunctionsYieldParameterNameInGenerator) {
};
const char* strict_function_context_data[][2] = {
- {"(function f() {'use strong'; (", "); });"},
{"(function f() {'use strict'; (", "); });"},
{NULL, NULL}
};
const char* generator_context_data[][2] = {
- {"(function *g() {'use strong'; (", "); });"},
{"(function *g() {'use strict'; (", "); });"},
{"(function *g() { (", "); });"},
{NULL, NULL}
@@ -4014,8 +3943,7 @@ TEST(ArrowFunctionsYieldParameterNameInGenerator) {
NULL
};
- static const ParserFlag always_flags[] = { kAllowHarmonyDestructuring,
- kAllowStrongMode};
+ static const ParserFlag always_flags[] = { kAllowHarmonyDestructuring };
RunParserSyncTest(sloppy_function_context_data, arrow_data, kSuccess, NULL, 0,
always_flags, arraysize(always_flags));
RunParserSyncTest(strict_function_context_data, arrow_data, kError, NULL, 0,
@@ -5971,12 +5899,6 @@ TEST(DeclarationsError) {
{"'use strict'; for (;;)", ""},
{"'use strict'; for (x in y)", ""},
{"'use strict'; do ", " while (false)"},
- {"'use strong'; if (true)", ""},
- {"'use strong'; if (false) {} else", ""},
- {"'use strong'; while (false)", ""},
- {"'use strong'; for (;;)", ""},
- {"'use strong'; for (x in y)", ""},
- {"'use strong'; do ", " while (false)"},
{NULL, NULL}};
const char* statement_data[] = {
@@ -5985,9 +5907,7 @@ TEST(DeclarationsError) {
"class C {}",
NULL};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kError);
}
@@ -6006,7 +5926,6 @@ void TestLanguageMode(const char* source,
i::Zone zone;
i::ParseInfo info(&zone, script);
i::Parser parser(&info);
- parser.set_allow_strong_mode(true);
info.set_global();
parser.Parse(&info);
CHECK(info.literal() != NULL);
@@ -6017,49 +5936,15 @@ void TestLanguageMode(const char* source,
TEST(LanguageModeDirectives) {
TestLanguageMode("\"use nothing\"", i::SLOPPY);
TestLanguageMode("\"use strict\"", i::STRICT);
- TestLanguageMode("\"use strong\"", i::STRONG);
TestLanguageMode("var x = 1; \"use strict\"", i::SLOPPY);
- TestLanguageMode("var x = 1; \"use strong\"", i::SLOPPY);
-
- // Test that multiple directives ("use strict" / "use strong") put the parser
- // into the correct mode.
- TestLanguageMode("\"use strict\"; \"use strong\";", i::STRONG);
- TestLanguageMode("\"use strong\"; \"use strict\";", i::STRONG);
TestLanguageMode("\"use some future directive\"; \"use strict\";", i::STRICT);
- TestLanguageMode("\"use some future directive\"; \"use strong\";", i::STRONG);
-}
-
-
-TEST(MultipleLanguageModeDirectives) {
- const char* context_data[][2] = {
- { "'use strict'; 'use strong';", "" },
- { "'use strong'; 'use strict';", "" },
- { "function f() { 'use strict'; 'use strong';", "}" },
- { "function f() { 'use strong'; 'use strict';", "}" },
- { NULL, NULL }
- };
-
- const char* strict_error_data[] = {
- "var x = 42; delete x",
- NULL};
-
- const char* strong_error_data[] = {
- "var x = 42",
- NULL};
-
- static const ParserFlag strong_mode_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, strict_error_data, kError,
- strong_mode_flags, arraysize(strong_mode_flags));
- RunParserSyncTest(context_data, strong_error_data, kError, NULL, 0,
- strong_mode_flags, arraysize(strong_mode_flags));
}
TEST(PropertyNameEvalArguments) {
const char* context_data[][2] = {{"'use strict';", ""},
- {"'use strong';", ""},
{NULL, NULL}};
const char* statement_data[] = {
@@ -6094,9 +5979,7 @@ TEST(PropertyNameEvalArguments) {
NULL};
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(context_data, statement_data, kSuccess);
}
@@ -6106,10 +5989,6 @@ TEST(FunctionLiteralDuplicateParameters) {
{"(function(", ") { 'use strict'; })();"},
{"'use strict'; function fn(", ") {}; fn();"},
{"function fn(", ") { 'use strict'; }; fn();"},
- {"'use strong';(function(", "){})();"},
- {"(function(", ") { 'use strong'; })();"},
- {"'use strong'; function fn(", ") {}; fn();"},
- {"function fn(", ") { 'use strong'; }; fn();"},
{NULL, NULL}};
const char* sloppy_context_data[][2] =
@@ -6127,451 +6006,8 @@ TEST(FunctionLiteralDuplicateParameters) {
"a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, w",
NULL};
- static const ParserFlag always_flags[] = { kAllowStrongMode };
- RunParserSyncTest(strict_context_data, data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
- RunParserSyncTest(sloppy_context_data, data, kSuccess, NULL, 0, NULL, 0);
-}
-
-
-TEST(VarForbiddenInStrongMode) {
- const char* strong_context_data[][2] =
- {{"'use strong'; ", ""},
- {"function f() {'use strong'; ", "}"},
- {"function f() {'use strong'; while (true) { ", "} }"},
- {NULL, NULL}};
-
- const char* strict_context_data[][2] =
- {{"'use strict'; ", ""},
- {"function f() {'use strict'; ", "}"},
- {"function f() {'use strict'; while (true) { ", "} }"},
- {NULL, NULL}};
-
- const char* sloppy_context_data[][2] =
- {{"", ""},
- {"function f() { ", "}"},
- {NULL, NULL}};
-
- const char* var_declarations[] = {
- "var x = 0;",
- "for (var i = 0; i < 10; i++) { }",
- NULL};
-
- const char* let_declarations[] = {
- "let x = 0;",
- "for (let i = 0; i < 10; i++) { }",
- NULL};
-
- const char* const_declarations[] = {
- "const x = 0;",
- NULL};
-
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(strong_context_data, var_declarations, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strong_context_data, let_declarations, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strong_context_data, const_declarations, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
-
- RunParserSyncTest(strict_context_data, var_declarations, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strict_context_data, let_declarations, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
-
- RunParserSyncTest(sloppy_context_data, var_declarations, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- // At the moment, let declarations are only available in strict mode.
- RunParserSyncTest(sloppy_context_data, let_declarations, kError, NULL, 0,
- always_flags, arraysize(always_flags));
-}
-
-
-TEST(StrongEmptySubStatements) {
- 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_error[] = {
- "if (1);",
- "if (1) {} else;",
- "while (1);",
- "do; while (1);",
- "for (;;);",
- "for (x in []);",
- "for (x of []);",
- "for (const x = 0;;);",
- "for (const x in []);",
- "for (const x of []);",
- NULL};
-
- const char* data_success[] = {
- "if (1) {} else {}",
- "switch(1) {}",
- "1+1;;",
- "1+1; ;",
- NULL};
-
- static const ParserFlag always_flags[] = {
- kAllowStrongMode,
- };
- RunParserSyncTest(sloppy_context_data, data_error, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strict_context_data, data_error, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strong_context_data, data_error, kError, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strong_context_data, data_success, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
-}
-
-
-TEST(StrongForIn) {
- 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[] = {
- "for (x in []) {}",
- "for (const x in []) {}",
- NULL};
-
- static const ParserFlag always_flags[] = {
- kAllowStrongMode,
- };
- RunParserSyncTest(sloppy_context_data, data, kSuccess, 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(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* 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; } }",
- "class C { constructor() { this.a = this.b; } }",
- "class C { constructor() { this.a = {b: 1}; this.a.b } }",
- "class C { constructor() { this.a = {b: 1}; this.a.b = 0 } }",
- "class C { constructor() { this.a = function(){}; this.a() } }",
- NULL};
-
- 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};
- 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() { 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); } }",
- "class C extends Object { constructor() { super().a; } }",
- NULL};
-
- const char* success_data[] = {
- "class C extends Object { constructor() { super(); } }",
- "class C extends Object { constructor() { label: 66; super(); } }",
- "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};
- 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(StrongConstructorReturns) {
- 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() { 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};
- 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(StrongConstructorDirective) {
- const char* context_data[][2] = {{"class c { ", " }"},
- {"(class c { ", " });"},
- {"let a = (class c { ", " });"},
- {NULL}};
-
- const char* error_data[] = {
- "constructor() { \"use strong\" }",
- "constructor(...rest) { \"use strong\" }",
- "foo() {} constructor() { \"use strong\" }",
- "foo(...rest) { \"use strict\" } constructor() { \"use strong\" }", NULL};
-
- const char* success_data[] = {
- "constructor() { \"use strict\" }", "foo() { \"use strong\" }",
- "foo() { \"use strong\" } constructor() {}", NULL};
-
- static const ParserFlag always_flags[] = {
- kAllowHarmonySloppy, kAllowHarmonySloppyLet, kAllowStrongMode};
-
- RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags,
- arraysize(always_flags));
- RunParserSyncTest(context_data, success_data, kSuccess, NULL, 0, always_flags,
- arraysize(always_flags));
-}
-
-
-TEST(StrongUndefinedLocal) {
- const char* context_data[][2] = {{"", ""}, {NULL}};
-
- const char* data[] = {
- "function undefined() {'use strong';}",
- "function* undefined() {'use strong';}",
- "(function undefined() {'use strong';});",
- "{foo: (function undefined(){'use strong';})};",
- "(function* undefined() {'use strong';})",
- "{foo: (function* undefined(){'use strong';})};",
- "function foo(a, b, undefined, c, d) {'use strong';}",
- "function* foo(a, b, undefined, c, d) {'use strong';}",
- "(function foo(a, b, undefined, c, d) {'use strong';})",
- "{foo: (function foo(a, b, undefined, c, d) {'use strong';})};",
- "(function* foo(a, b, undefined, c, d) {'use strong';})",
- "{foo: (function* foo(a, b, undefined, c, d) {'use strong';})};",
- "class C { foo(a, b, undefined, c, d) {'use strong';} }",
- "class C { *foo(a, b, undefined, c, d) {'use strong';} }",
- "({ foo(a, b, undefined, c, d) {'use strong';} });",
- "{ *foo(a, b, undefined, c, d) {'use strong';} });",
- "class undefined {'use strong'}",
- "(class undefined {'use strong'});",
- NULL};
-
- static const ParserFlag always_flags[] = {
- kAllowStrongMode, kAllowHarmonySloppy
- };
-
- RunParserSyncTest(context_data, data, kError, NULL, 0,
- always_flags, arraysize(always_flags));
-}
-
-
-TEST(StrongUndefinedArrow) {
- 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[] = {
- "(undefined => {return});",
- "((undefined, b, c) => {return});",
- "((a, undefined, c) => {return});",
- "((a, b, undefined) => {return});",
- NULL};
-
- const char* local_strong[] = {
- "(undefined => {'use strong';});",
- "((undefined, b, c) => {'use strong';});",
- "((a, undefined, c) => {'use strong';});",
- "((a, b, undefined) => {'use strong';});",
- NULL};
-
- static const ParserFlag always_flags[] = {kAllowStrongMode};
- RunParserSyncTest(sloppy_context_data, data, kSuccess, 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, local_strong, kError, NULL, 0,
- always_flags, arraysize(always_flags));
-}
-
-
-TEST(StrongDirectEval) {
- const char* sloppy_context_data[][2] = {{"", ""}, {NULL}};
- const char* strong_context_data[][2] = {{"'use strong';", ""}, {NULL}};
-
- const char* error_data[] = {
- "eval();",
- "eval([]);",
- "(eval)();",
- "(((eval)))();",
- "eval('function f() {}');",
- "function f() {eval()}",
- NULL};
-
- const char* success_data[] = {
- "eval;",
- "eval`foo`;",
- "let foo = eval; foo();",
- "(1, eval)();",
- NULL};
-
- static const ParserFlag always_flags[] = {
- kAllowStrongMode
- };
-
- RunParserSyncTest(sloppy_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(strong_context_data, success_data, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
-}
-
-
-TEST(StrongSwitchFallthrough) {
- const char* sloppy_context_data[][2] = {
- {"function f() { foo:for(;;) { switch(1) {", "};}}"},
- {NULL, NULL}
- };
- const char* strong_context_data[][2] = {
- {"function f() { 'use strong'; foo:for(;;) { switch(1) {", "};}}"},
- {NULL, NULL}
- };
-
- const char* data_success[] = {
- "",
- "case 1:",
- "case 1: case 2:",
- "case 1: break;",
- "default: throw new TypeError();",
- "case 1: case 2: null",
- "case 1: case 2: default: 1+1",
- "case 1: break; case 2: return; default:",
- "case 1: break foo; case 2: return; default:",
- "case 1: case 2: break; case 3: continue; case 4: default:",
- "case 1: case 2: break; case 3: continue foo; case 4: default:",
- "case 1: case 2: {{return;}} case 3: default:",
- "case 1: case 2: case 3: default: {1+1;{continue;}}",
- "case 1: case 2: {1+1;{1+1;{continue;}}} case 3: default:",
- "case 1: if (1) break; else continue; case 2: case 3: default:",
- "case 1: case 2: if (1) {{break;}} else break; case 3: default:",
- "case 1: if (1) break; else {if (1) break; else break;} case 2: default:",
- "case 1: if (1) {if (1) break; else break;} else break; case 2: default:",
- NULL};
-
- const char* data_error[] = {
- "case 1: case 2: (function(){return}); default:",
- "case 1: 1+1; case 2:",
- "case 1: bar: break bar; case 2: break;",
- "case 1: bar:return; case 2:",
- "case 1: bar:{ continue;} case 2:",
- "case 1: break; case 2: bar:{ throw new TypeError() } default:",
- "case 1: case 2: { bar:{ { break;} } } default: break;",
- "case 1: if (1) break; else {}; case 2: default:",
- "case 1: case 2: if (1) break; default:",
- "case 1: case 2: if (1) break; else 0; default:",
- "case 1: case 2: if (1) 0; else break; default:",
- "case 1: case 2: case 3: if (1) {} default:",
- "case 1: bar:if (1) break; else continue; case 2: case 3: default:",
- NULL};
-
- static const ParserFlag always_flags[] = {
- kAllowStrongMode
- };
- RunParserSyncTest(strong_context_data, data_success, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(sloppy_context_data, data_error, kSuccess, NULL, 0,
- always_flags, arraysize(always_flags));
- RunParserSyncTest(strong_context_data, data_error, kError, NULL, 0,
- always_flags, arraysize(always_flags));
+ RunParserSyncTest(strict_context_data, data, kError);
+ RunParserSyncTest(sloppy_context_data, data, kSuccess);
}
@@ -6591,101 +6027,6 @@ TEST(ArrowFunctionASIErrors) {
}
-TEST(StrongModeFreeVariablesDeclaredByPreviousScript) {
- i::FLAG_strong_mode = true;
- i::FLAG_legacy_const = true;
- v8::V8::Initialize();
- v8::HandleScope scope(CcTest::isolate());
- v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
- v8::TryCatch try_catch(CcTest::isolate());
-
- // Introduce a bunch of variables, in all language modes.
- const char* script1 =
- "var my_var1 = 0; \n"
- "function my_func1() { } \n"
- "const my_const1 = 0; \n";
- CompileRun(v8_str(script1));
- CHECK(!try_catch.HasCaught());
-
- const char* script2 =
- "\"use strict\"; \n"
- "let my_var2 = 0; \n"
- "function my_func2() { } \n"
- "const my_const2 = 0 \n";
- CompileRun(v8_str(script2));
- CHECK(!try_catch.HasCaught());
-
- const char* script3 =
- "\"use strong\"; \n"
- "let my_var3 = 0; \n"
- "function my_func3() { } \n"
- "const my_const3 = 0; \n";
- CompileRun(v8_str(script3));
- CHECK(!try_catch.HasCaught());
-
- // Sloppy eval introduces variables in the surrounding scope.
- const char* script4 =
- "eval('var my_var4 = 0;') \n"
- "eval('function my_func4() { }') \n"
- "eval('const my_const4 = 0;') \n";
- CompileRun(v8_str(script4));
- CHECK(!try_catch.HasCaught());
-
- // Test that referencing these variables work.
- const char* script5 =
- "\"use strong\"; \n"
- "my_var1; \n"
- "my_func1; \n"
- "my_const1; \n"
- "my_var2; \n"
- "my_func2; \n"
- "my_const2; \n"
- "my_var3; \n"
- "my_func3; \n"
- "my_const3; \n"
- "my_var4; \n"
- "my_func4; \n"
- "my_const4; \n";
- CompileRun(v8_str(script5));
- CHECK(!try_catch.HasCaught());
-}
-
-
-TEST(StrongModeFreeVariablesDeclaredByLanguage) {
- i::FLAG_strong_mode = true;
- v8::V8::Initialize();
- v8::HandleScope scope(CcTest::isolate());
- v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
- v8::TryCatch try_catch(CcTest::isolate());
-
- const char* script1 =
- "\"use strong\"; \n"
- "Math; \n"
- "RegExp; \n";
- CompileRun(v8_str(script1));
- CHECK(!try_catch.HasCaught());
-}
-
-
-TEST(StrongModeFreeVariablesDeclaredInGlobalPrototype) {
- i::FLAG_strong_mode = true;
- v8::V8::Initialize();
- v8::HandleScope scope(CcTest::isolate());
- v8::Context::Scope context_scope(v8::Context::New(CcTest::isolate()));
- v8::TryCatch try_catch(CcTest::isolate());
-
- const char* script1 = "this.__proto__.my_var = 0;\n";
- CompileRun(v8_str(script1));
- CHECK(!try_catch.HasCaught());
-
- const char* script2 =
- "\"use strong\"; \n"
- "my_var; \n";
- CompileRun(v8_str(script2));
- CHECK(!try_catch.HasCaught());
-}
-
-
static const ParserFlag kAllDestructuringFlags[] = {
kAllowHarmonyDestructuring, kAllowHarmonyDestructuringAssignment,
kAllowHarmonyDefaultParameters};
@@ -7411,7 +6752,6 @@ TEST(DefaultParametersYieldInInitializers) {
};
const char* strict_function_context_data[][2] = {
- {"'use strong'; (function f(", ") { });"},
{"'use strict'; (function f(", ") { });"},
{NULL, NULL}
};
@@ -7422,13 +6762,11 @@ TEST(DefaultParametersYieldInInitializers) {
};
const char* strict_arrow_context_data[][2] = {
- {"'use strong'; ((", ")=>{});"},
{"'use strict'; ((", ")=>{});"},
{NULL, NULL}
};
const char* generator_context_data[][2] = {
- {"'use strong'; (function *g(", ") { });"},
{"'use strict'; (function *g(", ") { });"},
{"(function *g(", ") { });"},
{NULL, NULL}
@@ -7463,8 +6801,7 @@ TEST(DefaultParametersYieldInInitializers) {
// clang-format on
static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring,
- kAllowHarmonyDefaultParameters,
- kAllowStrongMode};
+ kAllowHarmonyDefaultParameters};
RunParserSyncTest(sloppy_function_context_data, parameter_data, kSuccess,
NULL, 0, always_flags, arraysize(always_flags));
@@ -7651,59 +6988,24 @@ TEST(LanguageModeDirectivesNonSimpleParameterListErrors) {
// TC39 deemed "use strict" directives to be an error when occurring in the
// body of a function with non-simple parameter list, on 29/7/2015.
// https://goo.gl/ueA7Ln
- //
- // In V8, this also applies to "use strong " directives.
const char* context_data[][2] = {
{"function f(", ") { 'use strict'; }"},
- {"function f(", ") { 'use strong'; }"},
{"function* g(", ") { 'use strict'; }"},
- {"function* g(", ") { 'use strong'; }"},
{"class c { foo(", ") { 'use strict' }"},
- {"class c { foo(", ") { 'use strong' }"},
{"var a = (", ") => { 'use strict'; }"},
- {"var a = (", ") => { 'use strong'; }"},
{"var o = { m(", ") { 'use strict'; }"},
- {"var o = { m(", ") { 'use strong'; }"},
{"var o = { *gm(", ") { 'use strict'; }"},
- {"var o = { *gm(", ") { 'use strong'; }"},
{"var c = { m(", ") { 'use strict'; }"},
- {"var c = { m(", ") { 'use strong'; }"},
{"var c = { *gm(", ") { 'use strict'; }"},
- {"var c = { *gm(", ") { 'use strong'; }"},
{"'use strict'; function f(", ") { 'use strict'; }"},
- {"'use strict'; function f(", ") { 'use strong'; }"},
{"'use strict'; function* g(", ") { 'use strict'; }"},
- {"'use strict'; function* g(", ") { 'use strong'; }"},
{"'use strict'; class c { foo(", ") { 'use strict' }"},
- {"'use strict'; class c { foo(", ") { 'use strong' }"},
{"'use strict'; var a = (", ") => { 'use strict'; }"},
- {"'use strict'; var a = (", ") => { 'use strong'; }"},
{"'use strict'; var o = { m(", ") { 'use strict'; }"},
- {"'use strict'; var o = { m(", ") { 'use strong'; }"},
{"'use strict'; var o = { *gm(", ") { 'use strict'; }"},
- {"'use strict'; var o = { *gm(", ") { 'use strong'; }"},
{"'use strict'; var c = { m(", ") { 'use strict'; }"},
- {"'use strict'; var c = { m(", ") { 'use strong'; }"},
{"'use strict'; var c = { *gm(", ") { 'use strict'; }"},
- {"'use strict'; var c = { *gm(", ") { 'use strong'; }"},
-
- {"'use strong'; function f(", ") { 'use strict'; }"},
- {"'use strong'; function f(", ") { 'use strong'; }"},
- {"'use strong'; function* g(", ") { 'use strict'; }"},
- {"'use strong'; function* g(", ") { 'use strong'; }"},
- {"'use strong'; class c { foo(", ") { 'use strict' }"},
- {"'use strong'; class c { foo(", ") { 'use strong' }"},
- {"'use strong'; var a = (", ") => { 'use strict'; }"},
- {"'use strong'; var a = (", ") => { 'use strong'; }"},
- {"'use strong'; var o = { m(", ") { 'use strict'; }"},
- {"'use strong'; var o = { m(", ") { 'use strong'; }"},
- {"'use strong'; var o = { *gm(", ") { 'use strict'; }"},
- {"'use strong'; var o = { *gm(", ") { 'use strong'; }"},
- {"'use strong'; var c = { m(", ") { 'use strict'; }"},
- {"'use strong'; var c = { m(", ") { 'use strong'; }"},
- {"'use strong'; var c = { *gm(", ") { 'use strict'; }"},
- {"'use strong'; var c = { *gm(", ") { 'use strong'; }"},
{NULL, NULL}};
@@ -7726,7 +7028,7 @@ TEST(LanguageModeDirectivesNonSimpleParameterListErrors) {
static const ParserFlag always_flags[] = {
kAllowHarmonyDefaultParameters, kAllowHarmonyDestructuring,
- kAllowHarmonySloppy, kAllowStrongMode};
+ kAllowHarmonySloppy};
RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
arraysize(always_flags));
}
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/es6/classes-subclass-builtins.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698