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

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

Issue 6990056: Add tests for function statements in strict mode. (Closed)
Patch Set: Created 9 years, 7 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
« no previous file with comments | « test/preparser/strict-function-statement.pyt ('k') | no next file » | 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 """) 127 """)
128 128
129 postfix_var = StrictTemplate("postfix-$opname-$id", """ 129 postfix_var = StrictTemplate("postfix-$opname-$id", """
130 var x = $id$op; 130 var x = $id$op;
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", """
138 var x = {set foo($id) { }};
139 """)
140
137 non_strict_use = Template("nonstrict-$id", """ 141 non_strict_use = Template("nonstrict-$id", """
138 var $id = 42; 142 var $id = 42;
139 $id++; 143 $id++;
140 $id--; 144 $id--;
141 ++$id; 145 ++$id;
142 --$id; 146 --$id;
143 $id += 10; 147 $id += 10;
144 $id -= 10; 148 $id -= 10;
145 try {} catch ($id) { } 149 try {} catch ($id) { }
146 function $id($id) { } 150 function $id($id) { }
151 var x = {$id: 42};
152 x = {get $id() {}, set $id(value) {}};
147 function foo() { "use strict;" } 153 function foo() { "use strict;" }
148 var $id = 42; 154 var $id = 42;
149 $id++; 155 $id++;
150 $id--; 156 $id--;
151 ++$id; 157 ++$id;
152 --$id; 158 --$id;
153 $id += 10; 159 $id += 10;
154 $id -= 10; 160 $id -= 10;
155 try {} catch ($id) { } 161 try {} catch ($id) { }
156 function $id($id) { } 162 function $id($id) { }
163 x = {$id: 42};
164 x = {get $id() {}, set $id(value) {}};
157 """) 165 """)
158 166
159 # ---------------------------------------------------------------------- 167 # ----------------------------------------------------------------------
160 # Run tests 168 # Run tests
161 169
162 # eval and arguments have specific exceptions for different uses. 170 # eval and arguments have specific exceptions for different uses.
163 for id in ["eval", "arguments"]: 171 for id in ["eval", "arguments"]:
164 arg_name_own({"id": id}, "strict_param_name") 172 arg_name_own({"id": id}, "strict_param_name")
165 arg_name_nested({"id": id}, "strict_param_name") 173 arg_name_nested({"id": id}, "strict_param_name")
166 func_name_own({"id": id}, "strict_function_name") 174 func_name_own({"id": id}, "strict_function_name")
167 func_name_nested({"id": id}, "strict_function_name") 175 func_name_nested({"id": id}, "strict_function_name")
176 setter_arg({"id": id}, "strict_param_name")
168 for op in assign_ops.keys(): 177 for op in assign_ops.keys():
169 assign_var({"id": id, "op":op, "opname": assign_ops[op]}, 178 assign_var({"id": id, "op":op, "opname": assign_ops[op]},
170 "strict_lhs_assignment") 179 "strict_lhs_assignment")
171 catch_var({"id": id}, "strict_catch_variable") 180 catch_var({"id": id}, "strict_catch_variable")
172 declare_var({"id": id}, "strict_var_name") 181 declare_var({"id": id}, "strict_var_name")
173 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix") 182 prefix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_prefix")
174 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix") 183 prefix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_prefix")
175 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix") 184 postfix_var({"id": id, "op":"++", "opname":"inc"}, "strict_lhs_postfix")
176 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix") 185 postfix_var({"id": id, "op":"--", "opname":"dec"}, "strict_lhs_postfix")
177 non_strict_use({"id": id}, None) 186 non_strict_use({"id": id}, None)
178 187
179 188
180 # Reserved words just throw the same exception in all cases 189 # Reserved words just throw the same exception in all cases
181 # (with "const" being special, as usual). 190 # (with "const" being special, as usual).
182 for reserved_word in reserved_words + strict_reserved_words: 191 for reserved_word in reserved_words + strict_reserved_words:
183 message = "strict_reserved_word" 192 message = "strict_reserved_word"
184 if (reserved_word == "const"): message = "unexpected_token" 193 if (reserved_word == "const"): message = "unexpected_token"
185 arg_name_own({"id":reserved_word}, message) 194 arg_name_own({"id":reserved_word}, message)
186 arg_name_nested({"id":reserved_word}, message) 195 arg_name_nested({"id":reserved_word}, message)
196 setter_arg({"id": reserved_word}, message)
187 func_name_own({"id":reserved_word}, message) 197 func_name_own({"id":reserved_word}, message)
188 func_name_nested({"id":reserved_word}, message) 198 func_name_nested({"id":reserved_word}, message)
189 for op in assign_ops.keys(): 199 for op in assign_ops.keys():
190 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message) 200 assign_var({"id":reserved_word, "op":op, "opname": assign_ops[op]}, message)
191 catch_var({"id":reserved_word}, message) 201 catch_var({"id":reserved_word}, message)
192 declare_var({"id":reserved_word}, message) 202 declare_var({"id":reserved_word}, message)
193 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) 203 prefix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message)
194 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) 204 prefix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message)
195 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message) 205 postfix_var({"id":reserved_word, "op":"++", "opname":"inc"}, message)
196 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message) 206 postfix_var({"id":reserved_word, "op":"--", "opname":"dec"}, message)
197 read_var({"id": reserved_word}, message) 207 read_var({"id": reserved_word}, message)
198 208
199 209
OLDNEW
« no previous file with comments | « test/preparser/strict-function-statement.pyt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698