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

Side by Side Diff: test/mjsunit/es6/arguments-iterator.js

Issue 1332873002: Fixing Sloppy Symbol.iterator setter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« src/accessors.cc ('K') | « src/accessors.cc ('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 // Flags: --allow-natives-syntax 5 // Flags: --allow-natives-syntax
6 6
7 7
8 // Note in general that "arguments.foo" and "var o = arguments; o.foo" 8 // Note in general that "arguments.foo" and "var o = arguments; o.foo"
9 // are treated differently by full-codegen, and so both cases need to be 9 // are treated differently by full-codegen, and so both cases need to be
10 // tested. 10 // tested.
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 for (var entry of arguments) { 153 for (var entry of arguments) {
154 assertEquals([i, arguments[i]], entry); 154 assertEquals([i, arguments[i]], entry);
155 i++; 155 i++;
156 } 156 }
157 157
158 assertEquals(arguments.length, i); 158 assertEquals(arguments.length, i);
159 } 159 }
160 TestAssignmentToIterator(1, 2, 3, 4, 5); 160 TestAssignmentToIterator(1, 2, 3, 4, 5);
161 161
162 162
163 function TestAssignmentToIterator2() {
Camillo Bruni 2015/09/10 13:59:48 Do you add a regression/?? comment here?
Jakob Kummerow 2015/09/10 14:29:20 You certainly can. There's no formal syntax, I'd j
164 var i = 0;
165 arguments.__defineGetter__('callee', function(){});
166 arguments.__defineGetter__('length', function(){ return 1 });
167 arguments[Symbol.iterator] = [].entries;
168 for (var entry of arguments) {
169 assertEquals([i, arguments[i]], entry);
170 i++;
171 }
172
173 assertEquals(arguments.length, i);
174 }
175 TestAssignmentToIterator2(1, 2, 3, 4, 5);
176
Jakob Kummerow 2015/09/10 14:29:20 nit: two empty lines between top-level things
163 function TestArgumentsMutation() { 177 function TestArgumentsMutation() {
164 var i = 0; 178 var i = 0;
165 for (var x of arguments) { 179 for (var x of arguments) {
166 assertEquals(arguments[i], x); 180 assertEquals(arguments[i], x);
167 arguments[i+1] *= 2; 181 arguments[i+1] *= 2;
168 i++; 182 i++;
169 } 183 }
170 184
171 assertEquals(arguments.length, i); 185 assertEquals(arguments.length, i);
172 } 186 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 o = Object.freeze({__proto__:arguments}); 232 o = Object.freeze({__proto__:arguments});
219 assertSame([][Symbol.iterator], o[Symbol.iterator]); 233 assertSame([][Symbol.iterator], o[Symbol.iterator]);
220 assertFalse(o.hasOwnProperty(Symbol.iterator)); 234 assertFalse(o.hasOwnProperty(Symbol.iterator));
221 assertSame([][Symbol.iterator], o[Symbol.iterator]); 235 assertSame([][Symbol.iterator], o[Symbol.iterator]);
222 assertThrows(function () { o[Symbol.iterator] = 10 }); 236 assertThrows(function () { o[Symbol.iterator] = 10 });
223 assertFalse(o.hasOwnProperty(Symbol.iterator)); 237 assertFalse(o.hasOwnProperty(Symbol.iterator));
224 assertEquals([][Symbol.iterator], o[Symbol.iterator]); 238 assertEquals([][Symbol.iterator], o[Symbol.iterator]);
225 assertSame([][Symbol.iterator], arguments[Symbol.iterator]); 239 assertSame([][Symbol.iterator], arguments[Symbol.iterator]);
226 } 240 }
227 TestArgumentsAsProto(); 241 TestArgumentsAsProto();
OLDNEW
« src/accessors.cc ('K') | « src/accessors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698