| 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 7078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7089 "[ (...[a]) ]", | 7089 "[ (...[a]) ]", |
| 7090 "[ ...([a]) ]", | 7090 "[ ...([a]) ]", |
| 7091 "[ ...([a] = [])", | 7091 "[ ...([a] = [])", |
| 7092 "[ ...[ ( [ a ] ) ] ]", | 7092 "[ ...[ ( [ a ] ) ] ]", |
| 7093 "[ ([a]) ]", | 7093 "[ ([a]) ]", |
| 7094 "[ (...[a]) ]", | 7094 "[ (...[a]) ]", |
| 7095 "[ ([a] = []) ]", | 7095 "[ ([a] = []) ]", |
| 7096 "[ (++y) ]", | 7096 "[ (++y) ]", |
| 7097 "[ ...(++y) ]", | 7097 "[ ...(++y) ]", |
| 7098 | 7098 |
| 7099 "[ x += x ]", |
| 7100 "{ foo: x += x }", |
| 7101 |
| 7099 NULL}; | 7102 NULL}; |
| 7100 // clang-format on | 7103 // clang-format on |
| 7101 static const ParserFlag always_flags[] = { | 7104 static const ParserFlag always_flags[] = { |
| 7102 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, | 7105 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, |
| 7103 kAllowHarmonyDefaultParameters}; | 7106 kAllowHarmonyDefaultParameters}; |
| 7104 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7107 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 7105 arraysize(always_flags)); | 7108 arraysize(always_flags)); |
| 7106 | 7109 |
| 7107 const char* empty_context_data[][2] = { | 7110 const char* empty_context_data[][2] = { |
| 7108 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; | 7111 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; |
| 7109 | 7112 |
| 7110 // CoverInitializedName ambiguity handling in various contexts | 7113 // CoverInitializedName ambiguity handling in various contexts |
| 7111 const char* ambiguity_data[] = { | 7114 const char* ambiguity_data[] = { |
| 7112 "var foo = { x = 10 };", | 7115 "var foo = { x = 10 };", |
| 7113 "var foo = { q } = { x = 10 };", | 7116 "var foo = { q } = { x = 10 };", |
| 7114 "var foo; foo = { x = 10 };", | 7117 "var foo; foo = { x = 10 };", |
| 7115 "var foo; foo = { q } = { x = 10 };", | 7118 "var foo; foo = { q } = { x = 10 };", |
| 7116 "var x; ({ x = 10 });", | 7119 "var x; ({ x = 10 });", |
| 7117 "var q, x; ({ q } = { x = 10 });", | 7120 "var q, x; ({ q } = { x = 10 });", |
| 7118 "var x; [{ x = 10 }]", | 7121 "var x; [{ x = 10 }]", |
| 7119 "var x; (true ? { x = true } : { x = false })", | 7122 "var x; (true ? { x = true } : { x = false })", |
| 7120 "var q, x; (q, { x = 10 });", | 7123 "var q, x; (q, { x = 10 });", |
| 7121 "var { x = 10 } = { x = 20 };", | 7124 "var { x = 10 } = { x = 20 };", |
| 7122 "var { x = 10 } = (o = { x = 20 });", | 7125 "var { x = 10 } = (o = { x = 20 });", |
| 7123 "var x; (({ x = 10 } = { x = 20 }) => x)({})", | 7126 "var x; (({ x = 10 } = { x = 20 }) => x)({})", |
| 7127 |
| 7128 // Not ambiguous, but uses same context data |
| 7129 "switch([window %= []] = []) { default: }", |
| 7130 |
| 7124 NULL, | 7131 NULL, |
| 7125 }; | 7132 }; |
| 7126 RunParserSyncTest(empty_context_data, ambiguity_data, kError, NULL, 0, | 7133 RunParserSyncTest(empty_context_data, ambiguity_data, kError, NULL, 0, |
| 7127 always_flags, arraysize(always_flags)); | 7134 always_flags, arraysize(always_flags)); |
| 7128 | 7135 |
| 7129 // Strict mode errors | 7136 // Strict mode errors |
| 7130 const char* strict_context_data[][2] = {{"'use strict'; (", " = {})"}, | 7137 const char* strict_context_data[][2] = {{"'use strict'; (", " = {})"}, |
| 7131 {"'use strict'; for (", " of {}) {}"}, | 7138 {"'use strict'; for (", " of {}) {}"}, |
| 7132 {"'use strict'; for (", " in {}) {}"}, | 7139 {"'use strict'; for (", " in {}) {}"}, |
| 7133 {NULL, NULL}}; | 7140 {NULL, NULL}}; |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7823 } | 7830 } |
| 7824 | 7831 |
| 7825 | 7832 |
| 7826 TEST(MiscSyntaxErrors) { | 7833 TEST(MiscSyntaxErrors) { |
| 7827 const char* context_data[][2] = { | 7834 const char* context_data[][2] = { |
| 7828 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7835 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
| 7829 const char* error_data[] = {"for (();;) {}", NULL}; | 7836 const char* error_data[] = {"for (();;) {}", NULL}; |
| 7830 | 7837 |
| 7831 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7838 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
| 7832 } | 7839 } |
| OLD | NEW |