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

Side by Side Diff: test/mjsunit/harmony/array-from.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 | « src/prologue.js ('k') | test/mjsunit/harmony/array-of.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 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 // Flags: --harmony-arrays 5 // Flags: --harmony-arrays
6 (function() { 6 (function() {
7 7
8 assertEquals(1, Array.from.length); 8 assertEquals(1, Array.from.length);
9 9
10 function assertArrayLikeEquals(value, expected, type) { 10 function assertArrayLikeEquals(value, expected, type) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 testArrayFrom(Array, Array); 142 testArrayFrom(Array, Array);
143 testArrayFrom(null, Array); 143 testArrayFrom(null, Array);
144 testArrayFrom({}, Array); 144 testArrayFrom({}, Array);
145 testArrayFrom(Object, Object); 145 testArrayFrom(Object, Object);
146 testArrayFrom(Other, Other); 146 testArrayFrom(Other, Other);
147 testArrayFrom(Math.cos, Array); 147 testArrayFrom(Math.cos, Array);
148 testArrayFrom(Math.cos.bind(Math), Array); 148 testArrayFrom(Math.cos.bind(Math), Array);
149 testArrayFrom(boundFn, boundFn); 149 testArrayFrom(boundFn, boundFn);
150 150
151 // Assert that [[DefineOwnProperty]] is used in ArrayFrom, meaning a
152 // setter isn't called, and a failed [[DefineOwnProperty]] will throw.
153 var setterCalled = 0;
154 function exotic() {
155 Object.defineProperty(this, '0', {
156 get: function() { return 2; },
157 set: function() { setterCalled++; }
158 });
159 }
160 // Non-configurable properties can't be overwritten with DefineOwnProperty
161 assertThrows(function () { Array.from.call(exotic, [1]); }, TypeError);
162 // The setter wasn't called
163 assertEquals(0, setterCalled);
164
165 // Check that array properties defined are writable, enumerable, configurable
166 function ordinary() { }
167 var x = Array.from.call(ordinary, [2]);
168 var xlength = Object.getOwnPropertyDescriptor(x, 'length');
169 assertEquals(1, xlength.value);
170 assertEquals(true, xlength.writable);
171 assertEquals(true, xlength.enumerable);
172 assertEquals(true, xlength.configurable);
173 var x0 = Object.getOwnPropertyDescriptor(x, 0);
174 assertEquals(2, x0.value);
175 assertEquals(true, xlength.writable);
176 assertEquals(true, xlength.enumerable);
177 assertEquals(true, xlength.configurable);
178
151 })(); 179 })();
OLDNEW
« no previous file with comments | « src/prologue.js ('k') | test/mjsunit/harmony/array-of.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698