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

Side by Side Diff: test/mjsunit/regress/regress-builtinbust-6.js

Issue 254103002: Fix some more missing ToObject on Array.prototype. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/array.js ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Test that Array builtins can be called on primitive values. 5 // Test that Array builtins can be called on primitive values.
6 var values = [ 23, 4.2, true, false, 0/0 ]; 6 var values = [ 23, 4.2, true, false, 0/0 ];
7 for (var i = 0; i < values.length; ++i) { 7 for (var i = 0; i < values.length; ++i) {
8 var v = values[i]; 8 var v = values[i];
9 Array.prototype.join.call(v);
9 Array.prototype.pop.call(v); 10 Array.prototype.pop.call(v);
10 Array.prototype.push.call(v); 11 Array.prototype.push.call(v);
12 Array.prototype.reverse.call(v);
11 Array.prototype.shift.call(v); 13 Array.prototype.shift.call(v);
14 Array.prototype.slice.call(v);
15 Array.prototype.splice.call(v);
12 Array.prototype.unshift.call(v); 16 Array.prototype.unshift.call(v);
13 } 17 }
14 18
15 // Test that ToObject on primitive values is only called once. 19 // Test that ToObject on primitive values is only called once.
16 var length_receiver, element_receiver; 20 var length_receiver, element_receiver;
17 function length() { length_receiver = this; return 1; } 21 function length() { length_receiver = this; return 2; }
18 function element() { element_receiver = this; return "x"; } 22 function element() { element_receiver = this; return "x"; }
19 Object.defineProperty(Number.prototype, "length", { get:length, set:length }); 23 Object.defineProperty(Number.prototype, "length", { get:length, set:length });
20 Object.defineProperty(Number.prototype, "0", { get:element, set:element }); 24 Object.defineProperty(Number.prototype, "0", { get:element, set:element });
21 Object.defineProperty(Number.prototype, "1", { get:element, set:element }); 25 Object.defineProperty(Number.prototype, "1", { get:element, set:element });
26 Object.defineProperty(Number.prototype, "2", { get:element, set:element });
27 function test_receiver(expected, call_string) {
28 assertDoesNotThrow(call_string);
29 assertEquals(new Number(expected), length_receiver);
30 assertSame(length_receiver, element_receiver);
31 }
22 32
23 assertDoesNotThrow("Array.prototype.pop.call(23)"); 33 test_receiver(11, "Array.prototype.join.call(11)")
24 assertEquals(new Number(23), length_receiver); 34 test_receiver(23, "Array.prototype.pop.call(23)");
25 assertSame(length_receiver, element_receiver); 35 test_receiver(42, "Array.prototype.push.call(42, 'y')");
26 36 test_receiver(49, "Array.prototype.reverse.call(49)");
27 assertDoesNotThrow("Array.prototype.push.call(42, 'y')"); 37 test_receiver(65, "Array.prototype.shift.call(65)");
28 assertEquals(new Number(42), length_receiver); 38 test_receiver(77, "Array.prototype.slice.call(77, 1)");
29 assertSame(length_receiver, element_receiver); 39 test_receiver(88, "Array.prototype.splice.call(88, 1, 1)");
30 40 test_receiver(99, "Array.prototype.unshift.call(99, 'z')");
31 assertDoesNotThrow("Array.prototype.shift.call(65)");
32 assertEquals(new Number(65), length_receiver);
33 assertSame(length_receiver, element_receiver);
34
35 assertDoesNotThrow("Array.prototype.unshift.call(99, 'z')");
36 assertEquals(new Number(99), length_receiver);
37 assertSame(length_receiver, element_receiver);
OLDNEW
« no previous file with comments | « src/array.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698