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 28 matching lines...) Expand all Loading... |
39 // Temporary variable context allocation | 39 // Temporary variable context allocation |
40 function* g5(l) { "use strict"; yield 1; for (let x in l) { yield x; } } | 40 function* g5(l) { "use strict"; yield 1; for (let x in l) { yield x; } } |
41 | 41 |
42 g1(); | 42 g1(); |
43 g2(); | 43 g2(); |
44 g3(); | 44 g3(); |
45 g4(); | 45 g4(); |
46 g5(["foo"]); | 46 g5(["foo"]); |
47 } | 47 } |
48 | 48 |
| 49 // Test the properties and prototype of an iterator. |
| 50 function TestGeneratorIterator() { |
| 51 function* g() { yield 1; } |
| 52 |
| 53 var iterator = g(); |
| 54 assertSame(g.prototype, Object.getPrototypeOf(iterator)); |
| 55 assertTrue(iterator instanceof g); |
| 56 assertEquals([], Object.getOwnPropertyNames(iterator)); |
| 57 assertTrue(iterator !== g()); |
| 58 |
| 59 // g() is the same as new g(). |
| 60 iterator = new g(); |
| 61 assertSame(g.prototype, Object.getPrototypeOf(iterator)); |
| 62 assertTrue(iterator instanceof g); |
| 63 assertEquals([], Object.getOwnPropertyNames(iterator)); |
| 64 assertTrue(iterator !== new g()); |
| 65 } |
| 66 |
49 TestContextAllocation(); | 67 TestContextAllocation(); |
| 68 TestGeneratorIterator(); |
OLD | NEW |