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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 assertEquals(["done", "value"], property_names); | 46 assertEquals(["done", "value"], property_names); |
47 assertIteratorResult(1, false, result); | 47 assertIteratorResult(1, false, result); |
48 } | 48 } |
49 TestGeneratorResultPrototype() | 49 TestGeneratorResultPrototype() |
50 | 50 |
51 function TestGenerator(g, expected_values_for_next, | 51 function TestGenerator(g, expected_values_for_next, |
52 send_val, expected_values_for_send) { | 52 send_val, expected_values_for_send) { |
53 function testNext(thunk) { | 53 function testNext(thunk) { |
54 var iter = thunk(); | 54 var iter = thunk(); |
55 for (var i = 0; i < expected_values_for_next.length; i++) { | 55 for (var i = 0; i < expected_values_for_next.length; i++) { |
56 assertIteratorResult(expected_values_for_next[i], | 56 var v1 = expected_values_for_next[i]; |
57 i == expected_values_for_next.length - 1, | 57 var v2 = i == expected_values_for_next.length - 1; |
58 iter.next()); | 58 // var v3 = iter.next(); |
| 59 assertIteratorResult(v1, v2, iter.next()); |
59 } | 60 } |
60 assertThrows(function() { iter.next(); }, Error); | 61 assertThrows(function() { iter.next(); }, Error); |
61 } | 62 } |
62 function testSend(thunk) { | 63 function testSend(thunk) { |
63 var iter = thunk(); | 64 var iter = thunk(); |
64 for (var i = 0; i < expected_values_for_send.length; i++) { | 65 for (var i = 0; i < expected_values_for_send.length; i++) { |
65 assertIteratorResult(expected_values_for_send[i], | 66 assertIteratorResult(expected_values_for_send[i], |
66 i == expected_values_for_send.length - 1, | 67 i == expected_values_for_send.length - 1, |
67 iter.next(send_val)); | 68 iter.next(send_val)); |
68 } | 69 } |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 function TestThrowRecursion() { | 641 function TestThrowRecursion() { |
641 function* g() { yield iter.throw(1); } | 642 function* g() { yield iter.throw(1); } |
642 var iter = g(); | 643 var iter = g(); |
643 return iter.next(); | 644 return iter.next(); |
644 } | 645 } |
645 assertThrows(TestNextRecursion, Error); | 646 assertThrows(TestNextRecursion, Error); |
646 assertThrows(TestSendRecursion, Error); | 647 assertThrows(TestSendRecursion, Error); |
647 assertThrows(TestThrowRecursion, Error); | 648 assertThrows(TestThrowRecursion, Error); |
648 } | 649 } |
649 TestRecursion(); | 650 TestRecursion(); |
OLD | NEW |