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

Side by Side Diff: test/mjsunit/array-sort.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years 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/mjsunit/array-slice.js ('k') | test/mjsunit/array-splice.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 245
246 function TestNonArrayWithAccessors() { 246 function TestNonArrayWithAccessors() {
247 // Regression test for issue 346, more info at URL 247 // Regression test for issue 346, more info at URL
248 // http://code.google.com/p/v8/issues/detail?id=346 248 // http://code.google.com/p/v8/issues/detail?id=346
249 // Reported by nth10sd, test based on this report. 249 // Reported by nth10sd, test based on this report.
250 var x = {}; 250 var x = {};
251 x[0] = 42; 251 x[0] = 42;
252 x.__defineGetter__("1", function(){return this.foo;}); 252 x.__defineGetter__("1", function(){return this.foo;});
253 x.__defineSetter__("1", function(val){this.foo = val;}); 253 x.__defineSetter__("1", function(val){this.foo = val;});
254 x[1] = 49 254 x[1] = 49;
255 x[3] = 37; 255 x[3] = 37;
256 x.length = 4; 256 x.length = 4;
257 Array.prototype.sort.call(x); 257 Array.prototype.sort.call(x);
258 // Behavior of sort with accessors is undefined. This accessor is 258 // Behavior of sort with accessors is undefined. This accessor is
259 // well-behaved (acts like a normal property), so it should work. 259 // well-behaved (acts like a normal property), so it should work.
260 assertEquals(4, x.length, "sortaccessors length"); 260 assertEquals(4, x.length, "sortaccessors length");
261 assertEquals(37, x[0], "sortaccessors first"); 261 assertEquals(37, x[0], "sortaccessors first");
262 assertEquals(42, x[1], "sortaccessors second"); 262 assertEquals(42, x[1], "sortaccessors second");
263 assertEquals(49, x[2], "sortaccessors third") 263 assertEquals(49, x[2], "sortaccessors third");
264 assertFalse(3 in x, "sortaccessors fourth"); 264 assertFalse(3 in x, "sortaccessors fourth");
265 } 265 }
266 266
267 TestNonArrayWithAccessors(); 267 TestNonArrayWithAccessors();
268 268
269 269
270 function TestInheritedElementSort(depth) { 270 function TestInheritedElementSort(depth) {
271 var length = depth * 2 + 3; 271 var length = depth * 2 + 3;
272 var obj = {length: length}; 272 var obj = {length: length};
273 obj[depth * 2 + 1] = 0; 273 obj[depth * 2 + 1] = 0;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 362 }
363 }; 363 };
364 Array.prototype.sort.call(x); 364 Array.prototype.sort.call(x);
365 365
366 var name = "SpecialInherit-"; 366 var name = "SpecialInherit-";
367 367
368 assertEquals(10000, x.length, name + "length"); 368 assertEquals(10000, x.length, name + "length");
369 var sorted = ["a2", "a3", "b1", "b2", "c1", "c2", "d1", "d2", "e3", 369 var sorted = ["a2", "a3", "b1", "b2", "c1", "c2", "d1", "d2", "e3",
370 undefined, undefined, undefined]; 370 undefined, undefined, undefined];
371 for (var i = 0; i < sorted.length; i++) { 371 for (var i = 0; i < sorted.length; i++) {
372 assertTrue(x.hasOwnProperty(i), name + "has" + i) 372 assertTrue(x.hasOwnProperty(i), name + "has" + i);
373 assertEquals(sorted[i], x[i], name + i); 373 assertEquals(sorted[i], x[i], name + i);
374 } 374 }
375 assertFalse(x.hasOwnProperty(sorted.length), name + "haspost"); 375 assertFalse(x.hasOwnProperty(sorted.length), name + "haspost");
376 assertFalse(sorted.length in x, name + "haspost2"); 376 assertFalse(sorted.length in x, name + "haspost2");
377 assertTrue(x.hasOwnProperty(10), name + "hasundefined10"); 377 assertTrue(x.hasOwnProperty(10), name + "hasundefined10");
378 assertEquals(undefined, x[10], name + "undefined10"); 378 assertEquals(undefined, x[10], name + "undefined10");
379 assertTrue(x.hasOwnProperty(100), name + "hasundefined100"); 379 assertTrue(x.hasOwnProperty(100), name + "hasundefined100");
380 assertEquals(undefined, x[100], name + "undefined100"); 380 assertEquals(undefined, x[100], name + "undefined100");
381 assertTrue(x.hasOwnProperty(1000), name + "hasundefined1000"); 381 assertTrue(x.hasOwnProperty(1000), name + "hasundefined1000");
382 assertEquals(undefined, x[1000], name + "undefined1000"); 382 assertEquals(undefined, x[1000], name + "undefined1000");
(...skipping 14 matching lines...) Expand all
397 } 397 }
398 var arr = [o(1), o(2), o(4), o(8), o(16), o(32), o(64), o(128), o(256), o(-0)]; 398 var arr = [o(1), o(2), o(4), o(8), o(16), o(32), o(64), o(128), o(256), o(-0)];
399 var global = this; 399 var global = this;
400 function cmpTest(a, b) { 400 function cmpTest(a, b) {
401 assertEquals(global, this); 401 assertEquals(global, this);
402 assertTrue(a instanceof o); 402 assertTrue(a instanceof o);
403 assertTrue(b instanceof o); 403 assertTrue(b instanceof o);
404 return a.val - b.val; 404 return a.val - b.val;
405 } 405 }
406 arr.sort(cmpTest); 406 arr.sort(cmpTest);
OLDNEW
« no previous file with comments | « test/mjsunit/array-slice.js ('k') | test/mjsunit/array-splice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698