| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 i == expected_values_for_next.length - 1, | 57 i == expected_values_for_next.length - 1, |
| 58 iter.next()); | 58 iter.next()); |
| 59 } | 59 } |
| 60 assertThrows(function() { iter.next(); }, Error); | 60 assertThrows(function() { iter.next(); }, Error); |
| 61 } | 61 } |
| 62 function testSend(thunk) { | 62 function testSend(thunk) { |
| 63 var iter = thunk(); | 63 var iter = thunk(); |
| 64 for (var i = 0; i < expected_values_for_send.length; i++) { | 64 for (var i = 0; i < expected_values_for_send.length; i++) { |
| 65 assertIteratorResult(expected_values_for_send[i], | 65 assertIteratorResult(expected_values_for_send[i], |
| 66 i == expected_values_for_send.length - 1, | 66 i == expected_values_for_send.length - 1, |
| 67 iter.send(send_val)); | 67 iter.next(send_val)); |
| 68 } | 68 } |
| 69 assertThrows(function() { iter.send(send_val); }, Error); | 69 assertThrows(function() { iter.next(send_val); }, Error); |
| 70 } | 70 } |
| 71 function testThrow(thunk) { | 71 function testThrow(thunk) { |
| 72 for (var i = 0; i < expected_values_for_next.length; i++) { | 72 for (var i = 0; i < expected_values_for_next.length; i++) { |
| 73 var iter = thunk(); | 73 var iter = thunk(); |
| 74 for (var j = 0; j < i; j++) { | 74 for (var j = 0; j < i; j++) { |
| 75 assertIteratorResult(expected_values_for_next[j], | 75 assertIteratorResult(expected_values_for_next[j], |
| 76 j == expected_values_for_next.length - 1, | 76 j == expected_values_for_next.length - 1, |
| 77 iter.next()); | 77 iter.next()); |
| 78 } | 78 } |
| 79 function Sentinel() {} | 79 function Sentinel() {} |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 TestNestedTry(function (g) { return g(); }); | 565 TestNestedTry(function (g) { return g(); }); |
| 566 TestNestedTry(function* (g) { return yield* g(); }); | 566 TestNestedTry(function* (g) { return yield* g(); }); |
| 567 | 567 |
| 568 function TestRecursion() { | 568 function TestRecursion() { |
| 569 function TestNextRecursion() { | 569 function TestNextRecursion() { |
| 570 function* g() { yield iter.next(); } | 570 function* g() { yield iter.next(); } |
| 571 var iter = g(); | 571 var iter = g(); |
| 572 return iter.next(); | 572 return iter.next(); |
| 573 } | 573 } |
| 574 function TestSendRecursion() { | 574 function TestSendRecursion() { |
| 575 function* g() { yield iter.send(42); } | 575 function* g() { yield iter.next(42); } |
| 576 var iter = g(); | 576 var iter = g(); |
| 577 return iter.next(); | 577 return iter.next(); |
| 578 } | 578 } |
| 579 function TestThrowRecursion() { | 579 function TestThrowRecursion() { |
| 580 function* g() { yield iter.throw(1); } | 580 function* g() { yield iter.throw(1); } |
| 581 var iter = g(); | 581 var iter = g(); |
| 582 return iter.next(); | 582 return iter.next(); |
| 583 } | 583 } |
| 584 assertThrows(TestNextRecursion, Error); | 584 assertThrows(TestNextRecursion, Error); |
| 585 assertThrows(TestSendRecursion, Error); | 585 assertThrows(TestSendRecursion, Error); |
| 586 assertThrows(TestThrowRecursion, Error); | 586 assertThrows(TestThrowRecursion, Error); |
| 587 } | 587 } |
| 588 TestRecursion(); | 588 TestRecursion(); |
| OLD | NEW |