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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 | 93 |
94 // Functions that we associate with generator objects are actually defined by | 94 // Functions that we associate with generator objects are actually defined by |
95 // a common prototype. | 95 // a common prototype. |
96 function TestGeneratorObjectPrototype() { | 96 function TestGeneratorObjectPrototype() { |
97 assertSame(IteratorPrototype, | 97 assertSame(IteratorPrototype, |
98 Object.getPrototypeOf(GeneratorObjectPrototype)); | 98 Object.getPrototypeOf(GeneratorObjectPrototype)); |
99 assertSame(GeneratorObjectPrototype, | 99 assertSame(GeneratorObjectPrototype, |
100 Object.getPrototypeOf((function*(){yield 1}).prototype)); | 100 Object.getPrototypeOf((function*(){yield 1}).prototype)); |
101 | 101 |
102 var expected_property_names = ["next", "throw", "constructor"]; | 102 var expected_property_names = ["next", "return", "throw", "constructor"]; |
103 var found_property_names = | 103 var found_property_names = |
104 Object.getOwnPropertyNames(GeneratorObjectPrototype); | 104 Object.getOwnPropertyNames(GeneratorObjectPrototype); |
105 | 105 |
106 expected_property_names.sort(); | 106 expected_property_names.sort(); |
107 found_property_names.sort(); | 107 found_property_names.sort(); |
108 | 108 |
109 assertArrayEquals(expected_property_names, found_property_names); | 109 assertArrayEquals(expected_property_names, found_property_names); |
110 | 110 |
111 var constructor_desc = Object.getOwnPropertyDescriptor( | 111 var constructor_desc = Object.getOwnPropertyDescriptor( |
112 GeneratorObjectPrototype, "constructor"); | 112 GeneratorObjectPrototype, "constructor"); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 function TestPerGeneratorPrototype() { | 163 function TestPerGeneratorPrototype() { |
164 assertTrue((function*(){}).prototype !== (function*(){}).prototype); | 164 assertTrue((function*(){}).prototype !== (function*(){}).prototype); |
165 assertTrue((function*(){}).prototype !== g.prototype); | 165 assertTrue((function*(){}).prototype !== g.prototype); |
166 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); | 166 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); |
167 assertTrue(!(g.prototype instanceof Function)); | 167 assertTrue(!(g.prototype instanceof Function)); |
168 assertSame(typeof (g.prototype), "object"); | 168 assertSame(typeof (g.prototype), "object"); |
169 | 169 |
170 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); | 170 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); |
171 } | 171 } |
172 TestPerGeneratorPrototype(); | 172 TestPerGeneratorPrototype(); |
OLD | NEW |