| 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 6942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6953 "[x,,...z]", | 6953 "[x,,...z]", |
| 6954 "{ x: y }", | 6954 "{ x: y }", |
| 6955 "[x, y]", | 6955 "[x, y]", |
| 6956 "[((x, y) => z).x]", | 6956 "[((x, y) => z).x]", |
| 6957 "{x: ((y, z) => z).x}", | 6957 "{x: ((y, z) => z).x}", |
| 6958 "[((x, y) => z)['x']]", | 6958 "[((x, y) => z)['x']]", |
| 6959 "{x: ((y, z) => z)['x']}", | 6959 "{x: ((y, z) => z)['x']}", |
| 6960 | 6960 |
| 6961 "{x: { y = 10 } }", | 6961 "{x: { y = 10 } }", |
| 6962 "[(({ x } = { x: 1 }) => x).a]", | 6962 "[(({ x } = { x: 1 }) => x).a]", |
| 6963 |
| 6964 // v8:4662 |
| 6965 "{ x: (y) }", |
| 6966 "{ x: (y) = [] }", |
| 6967 "{ x: (foo.bar) }", |
| 6968 "{ x: (foo['bar']) }", |
| 6969 "[ ...(a) ]", |
| 6970 "[ ...(foo['bar']) ]", |
| 6971 "[ ...(foo.bar) ]", |
| 6972 "[ (y) ]", |
| 6973 "[ (foo.bar) ]", |
| 6974 "[ (foo['bar']) ]", |
| 6975 |
| 6963 NULL}; | 6976 NULL}; |
| 6964 // clang-format on | 6977 // clang-format on |
| 6965 static const ParserFlag always_flags[] = { | 6978 static const ParserFlag always_flags[] = { |
| 6966 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, | 6979 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, |
| 6967 kAllowHarmonyDefaultParameters}; | 6980 kAllowHarmonyDefaultParameters}; |
| 6968 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, | 6981 RunParserSyncTest(context_data, data, kSuccess, NULL, 0, always_flags, |
| 6969 arraysize(always_flags)); | 6982 arraysize(always_flags)); |
| 6970 | 6983 |
| 6971 RunParserSyncTest(mixed_assignments_context_data, data, kSuccess, NULL, 0, | 6984 RunParserSyncTest(mixed_assignments_context_data, data, kSuccess, NULL, 0, |
| 6972 always_flags, arraysize(always_flags)); | 6985 always_flags, arraysize(always_flags)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7059 "(({ x: x4, x: (x+=1e4) } = {}))", | 7072 "(({ x: x4, x: (x+=1e4) } = {}))", |
| 7060 "(({ x: x4, x: (x+=1e4) }) = {})", | 7073 "(({ x: x4, x: (x+=1e4) }) = {})", |
| 7061 "({ x: y } = {})", | 7074 "({ x: y } = {})", |
| 7062 "(({ x: y } = {}))", | 7075 "(({ x: y } = {}))", |
| 7063 "(({ x: y }) = {})", | 7076 "(({ x: y }) = {})", |
| 7064 "([a])", | 7077 "([a])", |
| 7065 "(([a]))", | 7078 "(([a]))", |
| 7066 "([a] = [])", | 7079 "([a] = [])", |
| 7067 "(([a] = []))", | 7080 "(([a] = []))", |
| 7068 "(([a]) = [])", | 7081 "(([a]) = [])", |
| 7082 |
| 7083 // v8:4662 |
| 7084 "{ x: ([y]) }", |
| 7085 "{ x: ([y] = []) }", |
| 7086 "{ x: ({y}) }", |
| 7087 "{ x: ({y} = {}) }", |
| 7088 "{ x: (++y) }", |
| 7089 "[ (...[a]) ]", |
| 7090 "[ ...([a]) ]", |
| 7091 "[ ...([a] = [])", |
| 7092 "[ ...[ ( [ a ] ) ] ]", |
| 7093 "[ ([a]) ]", |
| 7094 "[ (...[a]) ]", |
| 7095 "[ ([a] = []) ]", |
| 7096 "[ (++y) ]", |
| 7097 "[ ...(++y) ]", |
| 7098 |
| 7069 NULL}; | 7099 NULL}; |
| 7070 // clang-format on | 7100 // clang-format on |
| 7071 static const ParserFlag always_flags[] = { | 7101 static const ParserFlag always_flags[] = { |
| 7072 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, | 7102 kAllowHarmonyDestructuringAssignment, kAllowHarmonyDestructuring, |
| 7073 kAllowHarmonyDefaultParameters}; | 7103 kAllowHarmonyDefaultParameters}; |
| 7074 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7104 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
| 7075 arraysize(always_flags)); | 7105 arraysize(always_flags)); |
| 7076 | 7106 |
| 7077 const char* empty_context_data[][2] = { | 7107 const char* empty_context_data[][2] = { |
| 7078 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; | 7108 {"'use strict';", ""}, {"", ""}, {NULL, NULL}}; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7090 "var q, x; (q, { x = 10 });", | 7120 "var q, x; (q, { x = 10 });", |
| 7091 "var { x = 10 } = { x = 20 };", | 7121 "var { x = 10 } = { x = 20 };", |
| 7092 "var { x = 10 } = (o = { x = 20 });", | 7122 "var { x = 10 } = (o = { x = 20 });", |
| 7093 "var x; (({ x = 10 } = { x = 20 }) => x)({})", | 7123 "var x; (({ x = 10 } = { x = 20 }) => x)({})", |
| 7094 NULL, | 7124 NULL, |
| 7095 }; | 7125 }; |
| 7096 RunParserSyncTest(empty_context_data, ambiguity_data, kError, NULL, 0, | 7126 RunParserSyncTest(empty_context_data, ambiguity_data, kError, NULL, 0, |
| 7097 always_flags, arraysize(always_flags)); | 7127 always_flags, arraysize(always_flags)); |
| 7098 | 7128 |
| 7099 // Strict mode errors | 7129 // Strict mode errors |
| 7100 const char* strict_context_data[][2] = {{"'use strict'; ", " = {}"}, | 7130 const char* strict_context_data[][2] = {{"'use strict'; (", " = {})"}, |
| 7101 {"'use strict'; for (", " of {}) {}"}, | 7131 {"'use strict'; for (", " of {}) {}"}, |
| 7102 {"'use strict'; for (", " in {}) {}"}, | 7132 {"'use strict'; for (", " in {}) {}"}, |
| 7103 {NULL, NULL}}; | 7133 {NULL, NULL}}; |
| 7104 const char* strict_data[] = {"{ eval }", | 7134 const char* strict_data[] = {"{ eval }", |
| 7105 "{ arguments }", | 7135 "{ arguments }", |
| 7106 "{ foo: eval }", | 7136 "{ foo: eval }", |
| 7107 "{ foo: arguments }", | 7137 "{ foo: arguments }", |
| 7108 "{ eval = 0 }", | 7138 "{ eval = 0 }", |
| 7109 "{ arguments = 0 }", | 7139 "{ arguments = 0 }", |
| 7110 "{ foo: eval = 0 }", | 7140 "{ foo: eval = 0 }", |
| 7111 "{ foo: arguments = 0 }", | 7141 "{ foo: arguments = 0 }", |
| 7112 "[ eval ]", | 7142 "[ eval ]", |
| 7113 "[ arguments ]", | 7143 "[ arguments ]", |
| 7114 "[ eval = 0 ]", | 7144 "[ eval = 0 ]", |
| 7115 "[ arguments = 0 ]", | 7145 "[ arguments = 0 ]", |
| 7146 |
| 7147 // v8:4662 |
| 7148 "{ x: (eval) }", |
| 7149 "{ x: (arguments) }", |
| 7150 "{ x: (eval = 0) }", |
| 7151 "{ x: (arguments = 0) }", |
| 7152 "{ x: (eval) = 0 }", |
| 7153 "{ x: (arguments) = 0 }", |
| 7154 "[ (eval) ]", |
| 7155 "[ (arguments) ]", |
| 7156 "[ (eval = 0) ]", |
| 7157 "[ (arguments = 0) ]", |
| 7158 "[ (eval) = 0 ]", |
| 7159 "[ (arguments) = 0 ]", |
| 7160 "[ ...(eval) ]", |
| 7161 "[ ...(arguments) ]", |
| 7162 "[ ...(eval = 0) ]", |
| 7163 "[ ...(arguments = 0) ]", |
| 7164 "[ ...(eval) = 0 ]", |
| 7165 "[ ...(arguments) = 0 ]", |
| 7166 |
| 7116 NULL}; | 7167 NULL}; |
| 7117 RunParserSyncTest(strict_context_data, strict_data, kError, NULL, 0, | 7168 RunParserSyncTest(strict_context_data, strict_data, kError, NULL, 0, |
| 7118 always_flags, arraysize(always_flags)); | 7169 always_flags, arraysize(always_flags)); |
| 7119 } | 7170 } |
| 7120 | 7171 |
| 7121 | 7172 |
| 7122 TEST(DestructuringDisallowPatternsInForVarIn) { | 7173 TEST(DestructuringDisallowPatternsInForVarIn) { |
| 7123 i::FLAG_harmony_destructuring_bind = true; | 7174 i::FLAG_harmony_destructuring_bind = true; |
| 7124 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; | 7175 static const ParserFlag always_flags[] = {kAllowHarmonyDestructuring}; |
| 7125 const char* context_data[][2] = { | 7176 const char* context_data[][2] = { |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7772 } | 7823 } |
| 7773 | 7824 |
| 7774 | 7825 |
| 7775 TEST(MiscSyntaxErrors) { | 7826 TEST(MiscSyntaxErrors) { |
| 7776 const char* context_data[][2] = { | 7827 const char* context_data[][2] = { |
| 7777 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; | 7828 {"'use strict'", ""}, {"", ""}, {NULL, NULL}}; |
| 7778 const char* error_data[] = {"for (();;) {}", NULL}; | 7829 const char* error_data[] = {"for (();;) {}", NULL}; |
| 7779 | 7830 |
| 7780 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); | 7831 RunParserSyncTest(context_data, error_data, kError, NULL, 0, NULL, 0); |
| 7781 } | 7832 } |
| OLD | NEW |