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

Side by Side Diff: test/mjsunit/harmony/iteration-semantics.js

Issue 335423002: Add @@iterator support for strings (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed @@iterator property attributes Created 6 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 | Annotate | Revision Log
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 one_time_getter({ done: false }, 'value', 2), 212 one_time_getter({ done: false }, 'value', 2),
213 { value: 37, done: true }, 213 { value: 37, done: true },
214 never_getter(never_getter({}, 'done'), 'value')]))); 214 never_getter(never_getter({}, 'done'), 'value')])));
215 215
216 // Null and undefined do not cause an error. 216 // Null and undefined do not cause an error.
217 assertEquals(0, fold(sum, 0, unreachable(null))); 217 assertEquals(0, fold(sum, 0, unreachable(null)));
218 assertEquals(0, fold(sum, 0, unreachable(undefined))); 218 assertEquals(0, fold(sum, 0, unreachable(undefined)));
219 219
220 // Other non-iterators do cause an error. 220 // Other non-iterators do cause an error.
221 assertThrows('fold(sum, 0, unreachable({}))', TypeError); 221 assertThrows('fold(sum, 0, unreachable({}))', TypeError);
222 assertThrows('fold(sum, 0, unreachable("foo"))', TypeError); 222 assertThrows('fold(sum, 0, unreachable(false))', TypeError);
223 assertThrows('fold(sum, 0, unreachable(37))', TypeError); 223 assertThrows('fold(sum, 0, unreachable(37))', TypeError);
224 224
225 // "next" is looked up each time. 225 // "next" is looked up each time.
226 assertThrows('fold(sum, 0, remove_next_after(integers_until(10), 5))', 226 assertThrows('fold(sum, 0, remove_next_after(integers_until(10), 5))',
227 TypeError); 227 TypeError);
228 // It is not called at any other time. 228 // It is not called at any other time.
229 assertEquals(45, 229 assertEquals(45,
230 fold(sum, 0, remove_next_after(integers_until(10), 10))); 230 fold(sum, 0, remove_next_after(integers_until(10), 10)));
231 // It is not looked up too many times. 231 // It is not looked up too many times.
232 assertEquals(45, 232 assertEquals(45,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (name == 'next' && n-- < 0) throw "unreachable"; 329 if (name == 'next' && n-- < 0) throw "unreachable";
330 return iterator[name]; 330 return iterator[name];
331 }, 331 },
332 // Needed for integers_until(10)'s this.n++. 332 // Needed for integers_until(10)'s this.n++.
333 set: function(receiver, name, val) { 333 set: function(receiver, name, val) {
334 return iterator[name] = val; 334 return iterator[name] = val;
335 } 335 }
336 })); 336 }));
337 } 337 }
338 assertEquals(45, fold(sum, 0, poison_proxy_after(integers_until(10), 10))); 338 assertEquals(45, fold(sum, 0, poison_proxy_after(integers_until(10), 10)));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698