| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 throw (yield (1 + (yield 2) + 3)) | 317 throw (yield (1 + (yield 2) + 3)) |
| 318 } catch (e) { | 318 } catch (e) { |
| 319 if (typeof e == 'object') throw e; | 319 if (typeof e == 'object') throw e; |
| 320 return e + (yield (4 + (yield 5) + 6)); | 320 return e + (yield (4 + (yield 5) + 6)); |
| 321 } | 321 } |
| 322 }, | 322 }, |
| 323 [2, NaN, 5, NaN, NaN], | 323 [2, NaN, 5, NaN, NaN], |
| 324 "foo", | 324 "foo", |
| 325 [2, "1foo3", 5, "4foo6", "foofoo"]); | 325 [2, "1foo3", 5, "4foo6", "foofoo"]); |
| 326 | 326 |
| 327 // Generator function instances. |
| 328 TestGenerator(GeneratorFunction(), |
| 329 [undefined], |
| 330 "foo", |
| 331 [undefined]); |
| 332 |
| 333 TestGenerator(new GeneratorFunction(), |
| 334 [undefined], |
| 335 "foo", |
| 336 [undefined]); |
| 337 |
| 338 TestGenerator(GeneratorFunction('yield 1;'), |
| 339 [1, undefined], |
| 340 "foo", |
| 341 [1, undefined]); |
| 342 |
| 343 TestGenerator( |
| 344 function() { return GeneratorFunction('x', 'y', 'yield x + y;')(1, 2) }, |
| 345 [3, undefined], |
| 346 "foo", |
| 347 [3, undefined]); |
| 348 |
| 327 function TestTryCatch(instantiate) { | 349 function TestTryCatch(instantiate) { |
| 328 function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } | 350 function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } |
| 329 function Sentinel() {} | 351 function Sentinel() {} |
| 330 | 352 |
| 331 function Test1(iter) { | 353 function Test1(iter) { |
| 332 assertIteratorResult(1, false, iter.next()); | 354 assertIteratorResult(1, false, iter.next()); |
| 333 assertIteratorResult(2, false, iter.next()); | 355 assertIteratorResult(2, false, iter.next()); |
| 334 assertIteratorResult(3, false, iter.next()); | 356 assertIteratorResult(3, false, iter.next()); |
| 335 assertIteratorResult(undefined, true, iter.next()); | 357 assertIteratorResult(undefined, true, iter.next()); |
| 336 assertThrows(function() { iter.next(); }, Error); | 358 assertThrows(function() { iter.next(); }, Error); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 function TestThrowRecursion() { | 601 function TestThrowRecursion() { |
| 580 function* g() { yield iter.throw(1); } | 602 function* g() { yield iter.throw(1); } |
| 581 var iter = g(); | 603 var iter = g(); |
| 582 return iter.next(); | 604 return iter.next(); |
| 583 } | 605 } |
| 584 assertThrows(TestNextRecursion, Error); | 606 assertThrows(TestNextRecursion, Error); |
| 585 assertThrows(TestSendRecursion, Error); | 607 assertThrows(TestSendRecursion, Error); |
| 586 assertThrows(TestThrowRecursion, Error); | 608 assertThrows(TestThrowRecursion, Error); |
| 587 } | 609 } |
| 588 TestRecursion(); | 610 TestRecursion(); |
| OLD | NEW |