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

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: 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 // 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 // Check that exotic was defined right
161 var instance = new exotic();
162 assertEquals(2, instance[0]);
163 instance[0] = 1;
164 assertEquals(2, instance[0]);
165 assertEquals(1, setterCalled);
166 // Accessor properties can't be overwritten with DefineOwnProperty
167 assertThrows(function () { Array.from.call(exotic, [1]); }, TypeError);
168 assertEquals(1, setterCalled);
169
151 })(); 170 })();
arv (Not doing code reviews) 2015/06/11 13:04:01 I see that there is already a test for accessors o
Dan Ehrenberg 2015/06/11 16:27:25 Not sure what you're referring to, but I added a t
arv (Not doing code reviews) 2015/06/11 16:41:30 Ignore me.
OLDNEW
« src/harmony-array.js ('K') | « 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