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

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: 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
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 // Assert that [[DefineOwnProperty]] is used in ArrayFrom, meaning a
187 // setter isn't called, and a failed [[DefineOwnProperty]] will throw.
188 (function testDefinesOwnProperty() {
189 var setterCalled = 0;
190 function exotic() {
191 Object.defineProperty(this, '0', {
192 get: function() { return 2; },
193 set: function() { setterCalled++; }
194 });
195 }
196 // Check that exotic was defined right
197 var instance = new exotic();
198 assertEquals(2, instance[0]);
199 instance[0] = 1;
200 assertEquals(2, instance[0]);
201 assertEquals(1, setterCalled);
202 // Accessor properties can't be overwritten with DefineOwnProperty
203 assertThrows(function () { Array.of.call(exotic, 1); }, TypeError);
204 assertEquals(1, setterCalled);
205 })();
OLDNEW
« test/mjsunit/harmony/array-from.js ('K') | « test/mjsunit/harmony/array-from.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698