Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index a086c3ec617142db00252cb462ba2a06506ac4e3..1f880c53ce4b285264679e073a8141bd8c9c27ad 100644 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -4628,6 +4628,159 @@ TEST(ConstParsingInForInError) { |
} |
+TEST(InitializedDeclarationsInStrictForInError) { |
+ const char* context_data[][2] = {{"'use strict';", ""}, |
+ {"function foo(){ 'use strict';", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var i = 1 in {}) {}", |
+ "for (var i = void 0 in [1, 2, 3]) {}", |
+ "for (let i = 1 in {}) {}", |
+ "for (let i = void 0 in [1, 2, 3]) {}", |
+ "for (const i = 1 in {}) {}", |
+ "for (const i = void 0 in [1, 2, 3]) {}", |
+ NULL}; |
+ RunParserSyncTest(context_data, data, kError); |
+} |
+ |
+ |
+TEST(InitializedDeclarationsInStrictForOfError) { |
+ const char* context_data[][2] = {{"'use strict';", ""}, |
+ {"function foo(){ 'use strict';", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var i = 1 of {}) {}", |
+ "for (var i = void 0 of [1, 2, 3]) {}", |
+ "for (let i = 1 of {}) {}", |
+ "for (let i = void 0 of [1, 2, 3]) {}", |
+ "for (const i = 1 of {}) {}", |
+ "for (const i = void 0 of [1, 2, 3]) {}", |
+ NULL}; |
+ RunParserSyncTest(context_data, data, kError); |
+} |
+ |
+ |
+TEST(InitializedDeclarationsInSloppyForInError) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"function foo(){", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var i = 1 in {}) {}", |
+ "for (var i = void 0 in [1, 2, 3]) {}", |
+ NULL}; |
+ // TODO(caitp): This should be an error in sloppy mode. |
+ RunParserSyncTest(context_data, data, kSuccess); |
+} |
+ |
+ |
+TEST(InitializedDeclarationsInSloppyForOfError) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"function foo(){", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var i = 1 of {}) {}", |
+ "for (var i = void 0 of [1, 2, 3]) {}", |
+ NULL}; |
+ RunParserSyncTest(context_data, data, kError); |
+} |
+ |
+ |
+TEST(ForInMultipleDeclarationsError) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"function foo(){", "}"}, |
+ {"'use strict';", ""}, |
+ {"function foo(){ 'use strict';", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var i, j in {}) {}", |
+ "for (var i, j in [1, 2, 3]) {}", |
+ "for (var i, j = 1 in {}) {}", |
+ "for (var i, j = void 0 in [1, 2, 3]) {}", |
+ |
+ "for (let i, j in {}) {}", |
+ "for (let i, j in [1, 2, 3]) {}", |
+ "for (let i, j = 1 in {}) {}", |
+ "for (let i, j = void 0 in [1, 2, 3]) {}", |
+ |
+ "for (const i, j in {}) {}", |
+ "for (const i, j in [1, 2, 3]) {}", |
+ "for (const i, j = 1 in {}) {}", |
+ "for (const i, j = void 0 in [1, 2, 3]) {}", |
+ NULL}; |
+ static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
+TEST(ForOfMultipleDeclarationsError) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"function foo(){", "}"}, |
+ {"'use strict';", ""}, |
+ {"function foo(){ 'use strict';", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var i, j of {}) {}", |
+ "for (var i, j of [1, 2, 3]) {}", |
+ "for (var i, j = 1 of {}) {}", |
+ "for (var i, j = void 0 of [1, 2, 3]) {}", |
+ |
+ "for (let i, j of {}) {}", |
+ "for (let i, j of [1, 2, 3]) {}", |
+ "for (let i, j = 1 of {}) {}", |
+ "for (let i, j = void 0 of [1, 2, 3]) {}", |
+ |
+ "for (const i, j of {}) {}", |
+ "for (const i, j of [1, 2, 3]) {}", |
+ "for (const i, j = 1 of {}) {}", |
+ "for (const i, j = void 0 of [1, 2, 3]) {}", |
+ NULL}; |
+ static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
+TEST(ForInNoDeclarationsError) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"function foo(){", "}"}, |
+ {"'use strict';", ""}, |
+ {"function foo(){ 'use strict';", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var in {}) {}", |
+ "for (const in {}) {}", |
+ NULL}; |
+ static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
+TEST(ForOfNoDeclarationsError) { |
+ const char* context_data[][2] = {{"", ""}, |
+ {"function foo(){", "}"}, |
+ {"'use strict';", ""}, |
+ {"function foo(){ 'use strict';", "}"}, |
+ {NULL, NULL}}; |
+ |
+ const char* data[] = { |
+ "for (var of [1, 2, 3]) {}", |
+ "for (const of [1, 2, 3]) {}", |
+ NULL}; |
+ static const ParserFlag always_flags[] = {kAllowHarmonySloppy}; |
+ RunParserSyncTest(context_data, data, kError, nullptr, 0, always_flags, |
+ arraysize(always_flags)); |
+} |
+ |
+ |
TEST(InvalidUnicodeEscapes) { |
const char* context_data[][2] = {{"", ""}, |
{"'use strict';", ""}, |