| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 assertTrue(g instanceof GeneratorFunction); | 103 assertTrue(g instanceof GeneratorFunction); |
| 104 | 104 |
| 105 assertSame(Function, Object.getPrototypeOf(GeneratorFunction)); | 105 assertSame(Function, Object.getPrototypeOf(GeneratorFunction)); |
| 106 assertTrue(g instanceof Function); | 106 assertTrue(g instanceof Function); |
| 107 | 107 |
| 108 assertEquals("function* g() { yield 1; }", g.toString()); | 108 assertEquals("function* g() { yield 1; }", g.toString()); |
| 109 | 109 |
| 110 // Not all functions are generators. | 110 // Not all functions are generators. |
| 111 assertTrue(f instanceof Function); // Sanity check. | 111 assertTrue(f instanceof Function); // Sanity check. |
| 112 assertTrue(!(f instanceof GeneratorFunction)); | 112 assertTrue(!(f instanceof GeneratorFunction)); |
| 113 |
| 114 assertTrue((new GeneratorFunction()) instanceof GeneratorFunction); |
| 115 assertTrue(GeneratorFunction() instanceof GeneratorFunction); |
| 113 } | 116 } |
| 114 TestGeneratorFunction(); | 117 TestGeneratorFunction(); |
| 115 | 118 |
| 116 | 119 |
| 117 function TestPerGeneratorPrototype() { | 120 function TestPerGeneratorPrototype() { |
| 118 assertTrue((function*(){}).prototype !== (function*(){}).prototype); | 121 assertTrue((function*(){}).prototype !== (function*(){}).prototype); |
| 119 assertTrue((function*(){}).prototype !== g.prototype); | 122 assertTrue((function*(){}).prototype !== g.prototype); |
| 120 assertTrue(g.prototype instanceof GeneratorFunctionPrototype); | 123 assertTrue(g.prototype instanceof GeneratorFunctionPrototype); |
| 121 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); | 124 assertSame(GeneratorObjectPrototype, Object.getPrototypeOf(g.prototype)); |
| 122 assertTrue(!(g.prototype instanceof Function)); | 125 assertTrue(!(g.prototype instanceof Function)); |
| 123 assertSame(typeof (g.prototype), "object"); | 126 assertSame(typeof (g.prototype), "object"); |
| 124 | 127 |
| 125 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); | 128 assertArrayEquals([], Object.getOwnPropertyNames(g.prototype)); |
| 126 } | 129 } |
| 127 TestPerGeneratorPrototype(); | 130 TestPerGeneratorPrototype(); |
| OLD | NEW |