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

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

Issue 240223006: Fix ToObject and Object.isSealed in four Array builtins. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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
(Empty)
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
3 // found in the LICENSE file.
4
5 // Test that Array builtins can be called on primitive values.
6 var values = [ 23, 4.2, true, false, 0/0 ];
7 for (var i = 0; i < values.length; ++i) {
8 var v = values[i];
9 Array.prototype.pop.call(v);
10 Array.prototype.push.call(v);
11 Array.prototype.shift.call(v);
12 Array.prototype.unshift.call(v);
13 }
14
15 // Test that ToObject on primitive values is only called once.
16 var length_receiver, element_receiver;
17 function length() { length_receiver = this; return 1; }
18 function element() { element_receiver = this; return "x"; }
19 Object.defineProperty(Number.prototype, "length", { get:length, set:length });
20 Object.defineProperty(Number.prototype, "0", { get:element, set:element });
21 Object.defineProperty(Number.prototype, "1", { get:element, set:element });
22
23 assertDoesNotThrow("Array.prototype.pop.call(23)");
24 assertEquals(new Number(23), length_receiver);
25 assertSame(length_receiver, element_receiver);
26
27 assertDoesNotThrow("Array.prototype.push.call(42, 'y')");
28 assertEquals(new Number(42), length_receiver);
29 assertSame(length_receiver, element_receiver);
30
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