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

Side by Side Diff: test/mjsunit/harmony/array-of.js

Issue 1181623003: In Array.of and Array.from, fall back to DefineOwnProperty (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix %AddElement call, changed in rebase Created 5 years, 6 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 | « test/mjsunit/harmony/array-from.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 // Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/s ource/js/src/jit-test/tests/collections 5 // Based on Mozilla Array.of() tests at http://dxr.mozilla.org/mozilla-central/s ource/js/src/jit-test/tests/collections
6 6
7 // Flags: --harmony-arrays 7 // Flags: --harmony-arrays
8 8
9 9
10 10
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 }); 175 });
176 176
177 177
178 (function testBoundConstructor() { 178 (function testBoundConstructor() {
179 var boundFn = (function() {}).bind(null); 179 var boundFn = (function() {}).bind(null);
180 var instance = Array.of.call(boundFn, 1, 2, 3); 180 var instance = Array.of.call(boundFn, 1, 2, 3);
181 assertEquals(instance.length, 3); 181 assertEquals(instance.length, 3);
182 assertEquals(instance instanceof boundFn, true); 182 assertEquals(instance instanceof boundFn, true);
183 assertEquals(Array.isArray(instance), false); 183 assertEquals(Array.isArray(instance), false);
184 })(); 184 })();
185
186 (function testDefinesOwnProperty() {
187 // Assert that [[DefineOwnProperty]] is used in ArrayFrom, meaning a
188 // setter isn't called, and a failed [[DefineOwnProperty]] will throw.
189 var setterCalled = 0;
190 function exotic() {
191 Object.defineProperty(this, '0', {
192 get: function() { return 2; },
193 set: function() { setterCalled++; }
194 });
195 }
196 // Non-configurable properties can't be overwritten with DefineOwnProperty
197 assertThrows(function () { Array.of.call(exotic, 1); }, TypeError);
198 // The setter wasn't called
199 assertEquals(0, setterCalled);
200
201 // Check that array properties defined are writable, enumerable, configurable
202 function ordinary() { }
203 var x = Array.of.call(ordinary, 2);
204 var xlength = Object.getOwnPropertyDescriptor(x, 'length');
205 assertEquals(1, xlength.value);
206 assertEquals(true, xlength.writable);
207 assertEquals(true, xlength.enumerable);
208 assertEquals(true, xlength.configurable);
209 var x0 = Object.getOwnPropertyDescriptor(x, 0);
210 assertEquals(2, x0.value);
211 assertEquals(true, xlength.writable);
212 assertEquals(true, xlength.enumerable);
213 assertEquals(true, xlength.configurable);
214 })();
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/array-from.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698