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

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

Issue 669075: Fix a special case (zero length result array). (Closed)
Patch Set: Addressing Vitaly's concerns Created 10 years, 9 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 | « src/builtins.cc ('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 18 matching lines...) Expand all
29 (function() { 29 (function() {
30 var array = new Array(10); 30 var array = new Array(10);
31 for (var i = 0; i < 7; i++) { 31 for (var i = 0; i < 7; i++) {
32 var sliced = array.slice(); 32 var sliced = array.slice();
33 assertEquals(array.length, sliced.length); 33 assertEquals(array.length, sliced.length);
34 assertFalse(0 in sliced); 34 assertFalse(0 in sliced);
35 } 35 }
36 })(); 36 })();
37 37
38 38
39 // Check various variants of empty array's slicing.
40 (function() {
41 for (var i = 0; i < 7; i++) {
42 assertEquals([], [].slice(0, 0));
43 assertEquals([], [].slice(1, 0));
44 assertEquals([], [].slice(0, 1));
45 assertEquals([], [].slice(-1, 0));
46 }
47 })();
48
49
39 // Check various forms of arguments omission. 50 // Check various forms of arguments omission.
40 (function() { 51 (function() {
41 var array = new Array(7); 52 var array = new Array(7);
42 53
43 for (var i = 0; i < 7; i++) { 54 for (var i = 0; i < 7; i++) {
44 assertEquals(array, array.slice()); 55 assertEquals(array, array.slice());
45 assertEquals(array, array.slice(0)); 56 assertEquals(array, array.slice(0));
46 assertEquals(array, array.slice(undefined)); 57 assertEquals(array, array.slice(undefined));
47 assertEquals(array, array.slice("foobar")); 58 assertEquals(array, array.slice("foobar"));
48 assertEquals(array, array.slice(undefined, undefined)); 59 assertEquals(array, array.slice(undefined, undefined));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // ... but keeps the rest as holes: 164 // ... but keeps the rest as holes:
154 Array.prototype[5] = "@5"; 165 Array.prototype[5] = "@5";
155 assertEquals(array[5], Array.prototype[5]); 166 assertEquals(array[5], Array.prototype[5]);
156 assertFalse(array.hasOwnProperty(5)); 167 assertFalse(array.hasOwnProperty(5));
157 assertEquals(sliced[5], Array.prototype[5]); 168 assertEquals(sliced[5], Array.prototype[5]);
158 assertFalse(sliced.hasOwnProperty(5)); 169 assertFalse(sliced.hasOwnProperty(5));
159 170
160 assertTrue(delete Array.prototype[5]); 171 assertTrue(delete Array.prototype[5]);
161 } 172 }
162 })(); 173 })();
OLDNEW
« no previous file with comments | « src/builtins.cc ('k') | test/mjsunit/array-splice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698