| OLD | NEW |
| 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 7147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7158 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7158 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 7159 arraysize(always_flags)); | 7159 arraysize(always_flags)); |
| 7160 } | 7160 } |
| 7161 | 7161 |
| 7162 | 7162 |
| 7163 TEST(LetSloppyOnly) { | 7163 TEST(LetSloppyOnly) { |
| 7164 // clang-format off | 7164 // clang-format off |
| 7165 const char* context_data[][2] = { | 7165 const char* context_data[][2] = { |
| 7166 {"", ""}, | 7166 {"", ""}, |
| 7167 {"{", "}"}, | 7167 {"{", "}"}, |
| 7168 {"(function() {", "})()"}, |
| 7168 {NULL, NULL} | 7169 {NULL, NULL} |
| 7169 }; | 7170 }; |
| 7170 | 7171 |
| 7171 const char* data[] = { | 7172 const char* data[] = { |
| 7172 "let let", | |
| 7173 "let", | 7173 "let", |
| 7174 "let let = 1", | |
| 7175 "let = 1", | 7174 "let = 1", |
| 7176 "for (let let = 1; let < 1; let++) {}", | |
| 7177 "for (let = 1; let < 1; let++) {}", | 7175 "for (let = 1; let < 1; let++) {}", |
| 7178 "for (let let in {}) {}", | |
| 7179 "for (let let of []) {}", | |
| 7180 "for (let in {}) {}", | 7176 "for (let in {}) {}", |
| 7177 "for (var let = 1; let < 1; let++) {}", |
| 7178 "for (var let in {}) {}", |
| 7179 "for (var [let] = 1; let < 1; let++) {}", |
| 7180 "for (var [let] in {}) {}", |
| 7181 "var let", |
| 7182 // Unrelated parser crash BUG(v8:4462) |
| 7183 // "var [let]", |
| 7184 "for (const let = 1; let < 1; let++) {}", |
| 7185 "for (const let in {}) {}", |
| 7186 "for (const [let] = 1; let < 1; let++) {}", |
| 7187 // Unrelated parser crash BUG(v8:4461) |
| 7188 // "for (const [let] in {}) {}", |
| 7189 "const let", |
| 7190 "const [let]", |
| 7181 NULL | 7191 NULL |
| 7182 }; | 7192 }; |
| 7183 // clang-format on | 7193 // clang-format on |
| 7184 | 7194 |
| 7185 static const ParserFlag always_flags[] = {kAllowHarmonySloppy, | 7195 static const ParserFlag always_flags[] = { |
| 7186 kAllowHarmonySloppyLet}; | 7196 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kAllowHarmonyDestructuring}; |
| 7187 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 7197 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 7188 arraysize(always_flags)); | 7198 arraysize(always_flags)); |
| 7199 |
| 7200 // Some things should be rejected even in sloppy mode |
| 7201 // This addresses BUG(v8:4403). |
| 7202 |
| 7203 // clang-format off |
| 7204 const char* fail_data[] = { |
| 7205 "let let = 1", |
| 7206 "for (let let = 1; let < 1; let++) {}", |
| 7207 "for (let let in {}) {}", |
| 7208 "for (let let of []) {}", |
| 7209 "const let = 1", |
| 7210 "for (const let = 1; let < 1; let++) {}", |
| 7211 "for (const let in {}) {}", |
| 7212 "for (const let of []) {}", |
| 7213 "let [let] = 1", |
| 7214 "for (let [let] = 1; let < 1; let++) {}", |
| 7215 "for (let [let] in {}) {}", |
| 7216 "for (let [let] of []) {}", |
| 7217 "const [let] = 1", |
| 7218 "for (const [let] = 1; let < 1; let++) {}", |
| 7219 "for (const [let] in {}) {}", |
| 7220 "for (const [let] of []) {}", |
| 7221 NULL |
| 7222 }; |
| 7223 // clang-format on |
| 7224 |
| 7225 static const ParserFlag fail_flags[] = { |
| 7226 kAllowHarmonySloppy, kAllowHarmonySloppyLet, kNoLegacyConst, |
| 7227 kAllowHarmonyDestructuring}; |
| 7228 RunParserSyncTest(context_data, fail_data, kError, NULL, 0, fail_flags, |
| 7229 arraysize(fail_flags)); |
| 7189 } | 7230 } |
| OLD | NEW |