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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( | 241 TestGenerator( |
| 242 function* g20() { yield (1 + (yield 2) + 3); }, |
| 243 [2, NaN, undefined], |
| 244 "foo", |
| 245 [2, "1foo3", undefined]); |
| 246 |
| 247 TestGenerator( |
| 248 function* g21() { return (1 + (yield 2) + 3); }, |
| 249 [2, NaN], |
| 250 "foo", |
| 251 [2, "1foo3"]); |
| 252 |
| 253 TestGenerator( |
| 254 function* g22() { yield (1 + (yield 2) + 3); yield (4 + (yield 5) + 6); }, |
| 255 [2, NaN, 5, NaN, undefined], |
| 256 "foo", |
| 257 [2, "1foo3", 5, "4foo6", undefined]); |
| 258 |
| 259 TestGenerator( |
| 260 function* g23() { |
| 261 return (yield (1 + (yield 2) + 3)) + (yield (4 + (yield 5) + 6)); |
| 262 }, |
| 263 [2, NaN, 5, NaN, NaN], |
| 264 "foo", |
| 265 [2, "1foo3", 5, "4foo6", "foofoo"]); |
| 266 |
| 267 TestGenerator( |
242 function* g() { | 268 function* g() { |
243 var x = 1; | 269 var x = 1; |
244 yield x; | 270 yield x; |
245 with({x:2}) { yield x; } | 271 with({x:2}) { yield x; } |
246 yield x; | 272 yield x; |
247 }, | 273 }, |
248 [1, 2, 1, undefined], | 274 [1, 2, 1, undefined], |
249 "foo", | 275 "foo", |
250 [1, 2, 1, undefined]); | 276 [1, 2, 1, undefined]); |
251 | 277 |
(...skipping 11 matching lines...) Expand all Loading... |
263 function TestThrowRecursion() { | 289 function TestThrowRecursion() { |
264 function* g() { yield iter.throw(1); } | 290 function* g() { yield iter.throw(1); } |
265 var iter = g(); | 291 var iter = g(); |
266 return iter.next(); | 292 return iter.next(); |
267 } | 293 } |
268 assertThrows(TestNextRecursion, Error); | 294 assertThrows(TestNextRecursion, Error); |
269 assertThrows(TestSendRecursion, Error); | 295 assertThrows(TestSendRecursion, Error); |
270 assertThrows(TestThrowRecursion, Error); | 296 assertThrows(TestThrowRecursion, Error); |
271 } | 297 } |
272 TestRecursion(); | 298 TestRecursion(); |
OLD | NEW |