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

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: adding error handling 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
« no previous file with comments | « 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 // Regression test for crbug.com/521484.
164 function TestAssignmentToIterator2() {
165 var i = 0;
166 arguments.__defineGetter__('callee', function(){});
167 arguments.__defineGetter__('length', function(){ return 1 });
168 arguments[Symbol.iterator] = [].entries;
169 for (var entry of arguments) {
170 assertEquals([i, arguments[i]], entry);
171 i++;
172 }
173
174 assertEquals(arguments.length, i);
175 }
176 TestAssignmentToIterator2(1, 2, 3, 4, 5);
177
163 function TestArgumentsMutation() { 178 function TestArgumentsMutation() {
164 var i = 0; 179 var i = 0;
165 for (var x of arguments) { 180 for (var x of arguments) {
166 assertEquals(arguments[i], x); 181 assertEquals(arguments[i], x);
167 arguments[i+1] *= 2; 182 arguments[i+1] *= 2;
168 i++; 183 i++;
169 } 184 }
170 185
171 assertEquals(arguments.length, i); 186 assertEquals(arguments.length, i);
172 } 187 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 o = Object.freeze({__proto__:arguments}); 233 o = Object.freeze({__proto__:arguments});
219 assertSame([][Symbol.iterator], o[Symbol.iterator]); 234 assertSame([][Symbol.iterator], o[Symbol.iterator]);
220 assertFalse(o.hasOwnProperty(Symbol.iterator)); 235 assertFalse(o.hasOwnProperty(Symbol.iterator));
221 assertSame([][Symbol.iterator], o[Symbol.iterator]); 236 assertSame([][Symbol.iterator], o[Symbol.iterator]);
222 assertThrows(function () { o[Symbol.iterator] = 10 }); 237 assertThrows(function () { o[Symbol.iterator] = 10 });
223 assertFalse(o.hasOwnProperty(Symbol.iterator)); 238 assertFalse(o.hasOwnProperty(Symbol.iterator));
224 assertEquals([][Symbol.iterator], o[Symbol.iterator]); 239 assertEquals([][Symbol.iterator], o[Symbol.iterator]);
225 assertSame([][Symbol.iterator], arguments[Symbol.iterator]); 240 assertSame([][Symbol.iterator], arguments[Symbol.iterator]);
226 } 241 }
227 TestArgumentsAsProto(); 242 TestArgumentsAsProto();
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698