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

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

Issue 344223006: Simplify array iterator tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 function TestForArrayValues() { 168 function TestForArrayValues() {
169 var buffer = []; 169 var buffer = [];
170 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN]; 170 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN];
171 var i = 0; 171 var i = 0;
172 for (var value of array.values()) { 172 for (var value of array.values()) {
173 buffer[i++] = value; 173 buffer[i++] = value;
174 } 174 }
175 175
176 assertEquals(8, buffer.length); 176 assertEquals(8, buffer.length);
177 177
178 for (var i = 0; i < buffer.length - 1; i++) { 178 for (var i = 0; i < buffer.length; i++) {
179 assertSame(array[i], buffer[i]); 179 assertSame(array[i], buffer[i]);
180 } 180 }
181 assertTrue(isNaN(buffer[buffer.length - 1]));
182 } 181 }
183 TestForArrayValues(); 182 TestForArrayValues();
184 183
185 184
186 function TestForArrayKeys() { 185 function TestForArrayKeys() {
187 var buffer = []; 186 var buffer = [];
188 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN]; 187 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN];
189 var i = 0; 188 var i = 0;
190 for (var key of array.keys()) { 189 for (var key of array.keys()) {
191 buffer[i++] = key; 190 buffer[i++] = key;
(...skipping 11 matching lines...) Expand all
203 function TestForArrayEntries() { 202 function TestForArrayEntries() {
204 var buffer = []; 203 var buffer = [];
205 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN]; 204 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN];
206 var i = 0; 205 var i = 0;
207 for (var entry of array.entries()) { 206 for (var entry of array.entries()) {
208 buffer[i++] = entry; 207 buffer[i++] = entry;
209 } 208 }
210 209
211 assertEquals(8, buffer.length); 210 assertEquals(8, buffer.length);
212 211
213 for (var i = 0; i < buffer.length - 1; i++) { 212 for (var i = 0; i < buffer.length; i++) {
214 assertSame(array[i], buffer[i][1]); 213 assertSame(array[i], buffer[i][1]);
215 } 214 }
216 assertTrue(isNaN(buffer[buffer.length - 1][1]));
217 215
218 for (var i = 0; i < buffer.length; i++) { 216 for (var i = 0; i < buffer.length; i++) {
219 assertEquals(i, buffer[i][0]); 217 assertEquals(i, buffer[i][0]);
220 } 218 }
221 } 219 }
222 TestForArrayEntries(); 220 TestForArrayEntries();
223 221
224 222
225 function TestForArray() { 223 function TestForArray() {
226 var buffer = []; 224 var buffer = [];
227 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN]; 225 var array = [0, 'a', true, false, null, /* hole */, undefined, NaN];
228 var i = 0; 226 var i = 0;
229 for (var value of array) { 227 for (var value of array) {
230 buffer[i++] = value; 228 buffer[i++] = value;
231 } 229 }
232 230
233 assertEquals(8, buffer.length); 231 assertEquals(8, buffer.length);
234 232
235 for (var i = 0; i < buffer.length - 1; i++) { 233 for (var i = 0; i < buffer.length; i++) {
236 assertSame(array[i], buffer[i]); 234 assertSame(array[i], buffer[i]);
237 } 235 }
238 assertTrue(isNaN(buffer[buffer.length - 1]));
239 } 236 }
240 TestForArrayValues(); 237 TestForArrayValues();
241 238
242 239
243 function TestNonOwnSlots() { 240 function TestNonOwnSlots() {
244 var array = [0]; 241 var array = [0];
245 var iterator = array.values(); 242 var iterator = array.values();
246 var object = {__proto__: iterator}; 243 var object = {__proto__: iterator};
247 244
248 assertThrows(function() { 245 assertThrows(function() {
249 object.next(); 246 object.next();
250 }, TypeError); 247 }, TypeError);
251 } 248 }
252 TestNonOwnSlots(); 249 TestNonOwnSlots();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698