OLD | NEW |
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 ++$id; | 157 ++$id; |
158 --$id; | 158 --$id; |
159 $id += 10; | 159 $id += 10; |
160 $id -= 10; | 160 $id -= 10; |
161 try {} catch ($id) { } | 161 try {} catch ($id) { } |
162 function $id($id) { } | 162 function $id($id) { } |
163 x = {$id: 42}; | 163 x = {$id: 42}; |
164 x = {get $id() {}, set $id(value) {}}; | 164 x = {get $id() {}, set $id(value) {}}; |
165 """) | 165 """) |
166 | 166 |
| 167 identifier_name_source = """ |
| 168 var x = {$id: 42}; |
| 169 x = {get $id() {}, set $id(value) {}}; |
| 170 x.$id = 42; |
| 171 function foo() { "use strict;" } |
| 172 x = {$id: 42}; |
| 173 x = {get $id() {}, set $id(value) {}}; |
| 174 x.$id = 42; |
| 175 """ |
| 176 |
| 177 identifier_name = Template("identifier_name-$id", identifier_name_source) |
| 178 identifier_name_strict = StrictTemplate("identifier_name_strict-$id", |
| 179 identifier_name_source) |
| 180 |
167 # ---------------------------------------------------------------------- | 181 # ---------------------------------------------------------------------- |
168 # Run tests | 182 # Run tests |
169 | 183 |
170 # eval and arguments have specific exceptions for different uses. | 184 # eval and arguments have specific exceptions for different uses. |
171 for id in ["eval", "arguments"]: | 185 for id in ["eval", "arguments"]: |
172 arg_name_own({"id": id}, "strict_param_name") | 186 arg_name_own({"id": id}, "strict_param_name") |
173 arg_name_nested({"id": id}, "strict_param_name") | 187 arg_name_nested({"id": id}, "strict_param_name") |
174 func_name_own({"id": id}, "strict_function_name") | 188 func_name_own({"id": id}, "strict_function_name") |
175 func_name_nested({"id": id}, "strict_function_name") | 189 func_name_nested({"id": id}, "strict_function_name") |
176 setter_arg({"id": id}, "strict_param_name") | 190 setter_arg({"id": id}, "strict_param_name") |
177 for op in assign_ops.keys(): | 191 for op in assign_ops.keys(): |
178 assign_var({"id": id, "op":op, "opname": assign_ops[op]}, | 192 assign_var({"id": id, "op":op, "opname": assign_ops[op]}, |
179 "strict_lhs_assignment") | 193 "strict_lhs_assignment") |
180 catch_var({"id": id}, "strict_catch_variable") | 194 catch_var({"id": id}, "strict_catch_variable") |
181 declare_var({"id": id}, "strict_var_name") | 195 declare_var({"id": id}, "strict_var_name") |
182 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix") | 196 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix") |
183 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix") | 197 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix") |
184 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix") | 198 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix") |
185 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix") | 199 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix") |
186 non_strict_use({"id": id}, None) | 200 non_strict_use({"id": id}, None) |
187 | 201 |
188 | 202 |
189 # Reserved words just throw the same exception in all cases | 203 # Reserved words just throw the same exception in all cases |
190 # (with "const" being special, as usual). | 204 # (with "const" being special, as usual). |
191 for reserved_word in reserved_words + strict_reserved_words: | 205 for reserved_word in reserved_words + strict_reserved_words: |
192 message = "strict_reserved_word" | 206 if (reserved_word in strict_reserved_words): |
193 if (reserved_word == "const"): message = "unexpected_token" | 207 message = "strict_reserved_word" |
| 208 elif (reserved_word == "const"): |
| 209 message = "unexpected_token" |
| 210 else: |
| 211 message = "reserved_word" |
194 arg_name_own({"id":reserved_word}, message) | 212 arg_name_own({"id":reserved_word}, message) |
195 arg_name_nested({"id":reserved_word}, message) | 213 arg_name_nested({"id":reserved_word}, message) |
196 setter_arg({"id": reserved_word}, message) | 214 setter_arg({"id": reserved_word}, message) |
197 func_name_own({"id":reserved_word}, message) | 215 func_name_own({"id":reserved_word}, message) |
198 func_name_nested({"id":reserved_word}, message) | 216 func_name_nested({"id":reserved_word}, message) |
199 for op in assign_ops.keys(): | 217 for op in assign_ops.keys(): |
200 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message) | 218 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message) |
201 catch_var({"id":reserved_word}, message) | 219 catch_var({"id":reserved_word}, message) |
202 declare_var({"id":reserved_word}, message) | 220 declare_var({"id":reserved_word}, message) |
203 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) | 221 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) |
204 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) | 222 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) |
205 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) | 223 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) |
206 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) | 224 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) |
207 read_var({"id": reserved_word}, message) | 225 read_var({"id": reserved_word}, message) |
| 226 identifier_name({"id": reserved_word}, None); |
| 227 identifier_name_strict({"id": reserved_word}, None); |
208 | 228 |
209 | 229 |
| 230 # Future reserved words in strict mode behave like normal identifiers |
| 231 # in a non strict context. |
| 232 for reserved_word in strict_reserved_words: |
| 233 non_strict_use({"id": id}, None) |
OLD | NEW |