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

Side by Side Diff: test/preparser/strict-identifiers.pyt

Issue 8139027: Version 3.6.5 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mozilla/mozilla.status ('k') | test/sputnik/sputnik.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2011 the V8 project authors. All rights reserved. 1 # Copyright 2011 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 """) 131 """)
132 132
133 read_var = StrictTemplate("read-reserved-$id", """ 133 read_var = StrictTemplate("read-reserved-$id", """
134 var x = $id; 134 var x = $id;
135 """) 135 """)
136 136
137 setter_arg = StrictTemplate("setter-param-$id", """ 137 setter_arg = StrictTemplate("setter-param-$id", """
138 var x = {set foo($id) { }}; 138 var x = {set foo($id) { }};
139 """) 139 """)
140 140
141 label_normal = Template("label-normal-$id", """
142 $id: '';
143 """)
144
145 label_strict = StrictTemplate("label-strict-$id", """
146 $id: '';
147 """)
148
149 break_normal = Template("break-normal-$id", """
150 for (;;) {
151 break $id;
152 }
153 """)
154
155 break_strict = StrictTemplate("break-strict-$id", """
156 for (;;) {
157 break $id;
158 }
159 """)
160
161 continue_normal = Template("continue-normal-$id", """
162 for (;;) {
163 continue $id;
164 }
165 """)
166
167 continue_strict = StrictTemplate("continue-strict-$id", """
168 for (;;) {
169 continue $id;
170 }
171 """)
172
141 non_strict_use = Template("nonstrict-$id", """ 173 non_strict_use = Template("nonstrict-$id", """
142 var $id = 42; 174 var $id = 42;
143 $id++; 175 $id++;
144 $id--; 176 $id--;
145 ++$id; 177 ++$id;
146 --$id; 178 --$id;
147 $id += 10; 179 $id += 10;
148 $id -= 10; 180 $id -= 10;
149 try {} catch ($id) { } 181 try {} catch ($id) { }
150 function $id($id) { } 182 function $id($id) { }
151 var x = {$id: 42}; 183 var x = {$id: 42};
152 x = {get $id() {}, set $id(value) {}}; 184 x = {get $id() {}, set $id(value) {}};
153 function foo() { "use strict;" } 185 function foo() { "use strict;" }
154 var $id = 42; 186 var $id = 42;
155 $id++; 187 $id++;
156 $id--; 188 $id--;
157 ++$id; 189 ++$id;
158 --$id; 190 --$id;
159 $id += 10; 191 $id += 10;
160 $id -= 10; 192 $id -= 10;
161 try {} catch ($id) { } 193 try {} catch ($id) { }
162 function $id($id) { } 194 function $id($id) { }
163 x = {$id: 42}; 195 x = {$id: 42};
164 x = {get $id() {}, set $id(value) {}}; 196 x = {get $id() {}, set $id(value) {}};
197 $id: '';
165 """) 198 """)
166 199
167 identifier_name_source = """ 200 identifier_name_source = """
168 var x = {$id: 42}; 201 var x = {$id: 42};
169 x = {get $id() {}, set $id(value) {}}; 202 x = {get $id() {}, set $id(value) {}};
170 x.$id = 42; 203 x.$id = 42;
171 function foo() { "use strict;" } 204 function foo() { "use strict;" }
172 x = {$id: 42}; 205 x = {$id: 42};
173 x = {get $id() {}, set $id(value) {}}; 206 x = {get $id() {}, set $id(value) {}};
174 x.$id = 42; 207 x.$id = 42;
(...skipping 15 matching lines...) Expand all
190 setter_arg({"id": id}, "strict_param_name") 223 setter_arg({"id": id}, "strict_param_name")
191 for op in assign_ops.keys(): 224 for op in assign_ops.keys():
192 assign_var({"id": id, "op":op, "opname": assign_ops[op]}, 225 assign_var({"id": id, "op":op, "opname": assign_ops[op]},
193 "strict_lhs_assignment") 226 "strict_lhs_assignment")
194 catch_var({"id": id}, "strict_catch_variable") 227 catch_var({"id": id}, "strict_catch_variable")
195 declare_var({"id": id}, "strict_var_name") 228 declare_var({"id": id}, "strict_var_name")
196 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix") 229 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix")
197 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix") 230 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix")
198 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix") 231 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix")
199 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix") 232 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix")
233 label_normal({"id": id}, None)
234 label_strict({"id": id}, None)
235 break_normal({"id": id}, None)
236 break_strict({"id": id}, None)
237 continue_normal({"id": id}, None)
238 continue_strict({"id": id}, None)
200 non_strict_use({"id": id}, None) 239 non_strict_use({"id": id}, None)
201 240
202 241
203 # Reserved words just throw the same exception in all cases 242 # Reserved words just throw the same exception in all cases
204 # (with "const" being special, as usual). 243 # (with "const" being special, as usual).
205 for reserved_word in reserved_words + strict_reserved_words: 244 for reserved_word in reserved_words + strict_reserved_words:
206 if (reserved_word in strict_reserved_words): 245 if (reserved_word in strict_reserved_words):
207 message = "strict_reserved_word" 246 message = "strict_reserved_word"
247 label_message = None
208 elif (reserved_word == "const"): 248 elif (reserved_word == "const"):
209 message = "unexpected_token" 249 message = "unexpected_token"
250 label_message = message
210 else: 251 else:
211 message = "reserved_word" 252 message = "reserved_word"
253 label_message = message
212 arg_name_own({"id":reserved_word}, message) 254 arg_name_own({"id":reserved_word}, message)
213 arg_name_nested({"id":reserved_word}, message) 255 arg_name_nested({"id":reserved_word}, message)
214 setter_arg({"id": reserved_word}, message) 256 setter_arg({"id": reserved_word}, message)
215 func_name_own({"id":reserved_word}, message) 257 func_name_own({"id":reserved_word}, message)
216 func_name_nested({"id":reserved_word}, message) 258 func_name_nested({"id":reserved_word}, message)
217 for op in assign_ops.keys(): 259 for op in assign_ops.keys():
218 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message) 260 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message)
219 catch_var({"id":reserved_word}, message) 261 catch_var({"id":reserved_word}, message)
220 declare_var({"id":reserved_word}, message) 262 declare_var({"id":reserved_word}, message)
221 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) 263 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message)
222 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) 264 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message)
223 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) 265 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message)
224 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) 266 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message)
225 read_var({"id": reserved_word}, message) 267 read_var({"id": reserved_word}, message)
226 identifier_name({"id": reserved_word}, None); 268 identifier_name({"id": reserved_word}, None);
227 identifier_name_strict({"id": reserved_word}, None); 269 identifier_name_strict({"id": reserved_word}, None);
270 label_normal({"id": reserved_word}, label_message)
271 break_normal({"id": reserved_word}, label_message)
272 continue_normal({"id": reserved_word}, label_message)
273 if (reserved_word == "const"):
274 # The error message for this case is different because
275 # ParseLabelledStatementOrExpression will try to parse this as an expression
276 # first, effectively disallowing the use in ParseVariableDeclarations, i.e.
277 # the preparser never sees that 'const' was intended to be a label.
278 label_strict({"id": reserved_word}, "strict_const")
279 else:
280 label_strict({"id": reserved_word}, message)
281 break_strict({"id": reserved_word}, message)
282 continue_strict({"id": reserved_word}, message)
228 283
229 284
230 # Future reserved words in strict mode behave like normal identifiers 285 # Future reserved words in strict mode behave like normal identifiers
231 # in a non strict context. 286 # in a non strict context.
232 for reserved_word in strict_reserved_words: 287 for reserved_word in strict_reserved_words:
233 non_strict_use({"id": id}, None) 288 non_strict_use({"id": id}, None)
OLDNEW
« no previous file with comments | « test/mozilla/mozilla.status ('k') | test/sputnik/sputnik.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698