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 27 matching lines...) Expand all Loading... | |
38 function* g4() { var x = 10; yield 1; return x; } | 38 function* g4() { var x = 10; yield 1; return x; } |
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 TestContextAllocation(); | |
48 | 49 |
Michael Starzinger
2013/04/11 19:17:39
nit: Add a second empty newline between the two te
wingo
2013/04/12 10:50:17
Done.
| |
49 TestContextAllocation(); | 50 // Test the properties and prototype of a generator object. |
51 function TestGeneratorObject() { | |
52 function* g() { yield 1; } | |
53 | |
54 var iter = g(); | |
55 assertSame(g.prototype, Object.getPrototypeOf(iter)); | |
56 assertTrue(iter instanceof g); | |
57 assertEquals([], Object.getOwnPropertyNames(iter)); | |
58 assertTrue(iter !== g()); | |
59 | |
60 // g() is the same as new g(). | |
61 iter = new g(); | |
62 assertSame(g.prototype, Object.getPrototypeOf(iter)); | |
63 assertTrue(iter instanceof g); | |
64 assertEquals([], Object.getOwnPropertyNames(iter)); | |
65 assertTrue(iter !== new g()); | |
66 } | |
67 TestGeneratorObject(); | |
OLD | NEW |