OLD | NEW |
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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return iter; | 231 return iter; |
232 }, | 232 }, |
233 [1, 2, undefined], | 233 [1, 2, undefined], |
234 "foo", | 234 "foo", |
235 [1, 2, undefined]); | 235 [1, 2, undefined]); |
236 } | 236 } |
237 // TODO(wingo): Enable this test. Currently accessing "this" doesn't work as | 237 // TODO(wingo): Enable this test. Currently accessing "this" doesn't work as |
238 // prior to generators, nothing needed to heap-allocate the receiver. | 238 // prior to generators, nothing needed to heap-allocate the receiver. |
239 // TestReceivers(); | 239 // TestReceivers(); |
240 | 240 |
| 241 TestGenerator( |
| 242 function* g() { |
| 243 var x = 1; |
| 244 yield x; |
| 245 with({x:2}) { yield x; } |
| 246 yield x; |
| 247 }, |
| 248 [1, 2, 1, undefined], |
| 249 "foo", |
| 250 [1, 2, 1, undefined]); |
| 251 |
241 function TestRecursion() { | 252 function TestRecursion() { |
242 function TestNextRecursion() { | 253 function TestNextRecursion() { |
243 function* g() { yield iter.next(); } | 254 function* g() { yield iter.next(); } |
244 var iter = g(); | 255 var iter = g(); |
245 return iter.next(); | 256 return iter.next(); |
246 } | 257 } |
247 function TestSendRecursion() { | 258 function TestSendRecursion() { |
248 function* g() { yield iter.send(42); } | 259 function* g() { yield iter.send(42); } |
249 var iter = g(); | 260 var iter = g(); |
250 return iter.next(); | 261 return iter.next(); |
251 } | 262 } |
252 function TestThrowRecursion() { | 263 function TestThrowRecursion() { |
253 function* g() { yield iter.throw(1); } | 264 function* g() { yield iter.throw(1); } |
254 var iter = g(); | 265 var iter = g(); |
255 return iter.next(); | 266 return iter.next(); |
256 } | 267 } |
257 assertThrows(TestNextRecursion, Error); | 268 assertThrows(TestNextRecursion, Error); |
258 assertThrows(TestSendRecursion, Error); | 269 assertThrows(TestSendRecursion, Error); |
259 assertThrows(TestThrowRecursion, Error); | 270 assertThrows(TestThrowRecursion, Error); |
260 } | 271 } |
261 TestRecursion(); | 272 TestRecursion(); |
OLD | NEW |