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

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

Issue 1804963002: [builtins] Fix Array.prototype.concat bug (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: polishing corner cases and making tests work Created 4 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/elements.cc ('k') | test/mjsunit/es6/array-concat.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 11 matching lines...) Expand all
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 /** 28 /**
29 * @fileoverview Test concat on small and large arrays 29 * @fileoverview Test concat on small and large arrays
30 */ 30 */
31 31
32
33 (function testStringWrapperConcat() {
34 var concat = Array.prototype.concat;
35 var str = new String('abcd');
36 assertEquals([1,2,3,new String('abcd')], [1, 2, 3].concat(str));
37 assertEquals([new String("abcd")], concat.call(str));
38
39 var array = [1, 2, 3];
40 array.__proto__ = str;
41 array.length = 4;
42 assertEquals([1,2,3,'d'], concat.call(array));
43 })()
44
32 var poses; 45 var poses;
33 46
34 poses = [140, 4000000000]; 47 poses = [140, 4000000000];
35 while (pos = poses.shift()) { 48 while (pos = poses.shift()) {
36 var a = new Array(pos); 49 var a = new Array(pos);
37 var array_proto = []; 50 var array_proto = [];
38 a.__proto__ = array_proto; 51 a.__proto__ = array_proto;
39 assertEquals(pos, a.length); 52 assertEquals(pos, a.length);
40 a.push('foo'); 53 a.push('foo');
41 assertEquals(pos + 1, a.length); 54 assertEquals(pos + 1, a.length);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 function mkGetter(i) { return function() { trace.push(i); }; } 241 function mkGetter(i) { return function() { trace.push(i); }; }
229 arr3.length = 10000; 242 arr3.length = 10000;
230 for (var i = 0; i < 100; i++) { 243 for (var i = 0; i < 100; i++) {
231 Object.defineProperty(arr3, i * i, {get: mkGetter(i)}); 244 Object.defineProperty(arr3, i * i, {get: mkGetter(i)});
232 expectedTrace[i] = i; 245 expectedTrace[i] = i;
233 expectedTrace[100 + i] = i; 246 expectedTrace[100 + i] = i;
234 } 247 }
235 var r4 = [0].concat(arr3, arr3); 248 var r4 = [0].concat(arr3, arr3);
236 assertEquals(1 + arr3.length * 2, r4.length); 249 assertEquals(1 + arr3.length * 2, r4.length);
237 assertEquals(expectedTrace, trace); 250 assertEquals(expectedTrace, trace);
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | test/mjsunit/es6/array-concat.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698