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

Side by Side Diff: test/mjsunit/object-literal.js

Issue 493173003: Fix issue with numeric property names (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 | « src/preparser.cc ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 function construct() { this.constructed = true; } 183 function construct() { this.constructed = true; }
184 var v = eval("({" + keyword + ": construct})"); 184 var v = eval("({" + keyword + ": construct})");
185 var vo = eval("new v." + keyword + "()"); 185 var vo = eval("new v." + keyword + "()");
186 assertTrue(vo instanceof construct); 186 assertTrue(vo instanceof construct);
187 assertTrue(vo.constructed); 187 assertTrue(vo.constructed);
188 } 188 }
189 189
190 for (var i = 0; i < keywords.length; i++) { 190 for (var i = 0; i < keywords.length; i++) {
191 testKeywordProperty(keywords[i]); 191 testKeywordProperty(keywords[i]);
192 } 192 }
193
194
195 (function TestNumericNames() {
196 var o = {
197 1: 1,
198 2.: 2,
199 3.0: 3,
200 4e0: 4,
201 5E0: 5,
202 6e-0: 6,
203 7E-0: 7,
204 0x8: 8,
205 0X9: 9,
206 }
207 assertEquals(['1', '2', '3', '4', '5', '6', '7', '8', '9'], Object.keys(o));
208
209 o = {
210 1.2: 1.2,
211 1.30: 1.3
212 };
213 assertEquals(['1.2', '1.3'], Object.keys(o));
214 })();
215
216
217 function TestNumericNamesGetter(expectedKeys, object) {
218 assertEquals(expectedKeys, Object.keys(object));
219 expectedKeys.forEach(function(key) {
220 var descr = Object.getOwnPropertyDescriptor(object, key);
221 assertEquals(key, descr.get.name);
222 });
223 }
224 TestNumericNamesGetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
225 get 1() {},
226 get 2.() {},
227 get 3.0() {},
228 get 4e0() {},
229 get 5E0() {},
230 get 6e-0() {},
231 get 7E-0() {},
232 get 0x8() {},
233 get 0X9() {},
234 });
235 TestNumericNamesGetter(['1.2', '1.3'], {
236 get 1.2() {},
237 get 1.30() {}
238 });
239
240
241 function TestNumericNamesSetter(expectedKeys, object) {
242 assertEquals(expectedKeys, Object.keys(object));
243 expectedKeys.forEach(function(key) {
244 var descr = Object.getOwnPropertyDescriptor(object, key);
245 assertEquals(key, descr.set.name);
246 });
247 }
248 TestNumericNamesSetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
249 set 1(_) {},
250 set 2.(_) {},
251 set 3.0(_) {},
252 set 4e0(_) {},
253 set 5E0(_) {},
254 set 6e-0(_) {},
255 set 7E-0(_) {},
256 set 0x8(_) {},
257 set 0X9(_) {},
258 });
259 TestNumericNamesSetter(['1.2', '1.3'], {
260 set 1.2(_) {; },
261 set 1.30(_) {; }
262 });
OLDNEW
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698