| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0e821ff commit fee0389
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3021,3 +3021,35 @@ assert.strictEqual( | |||
| 3021 | 3021 | '}' | |
| 3022 | 3022 | ); | |
| 3023 | 3023 | } | |
| 3024 | + | ||
| 3025 | + { | ||
| 3026 | + // Confirm null prototype of generator prototype displays as expected. | ||
| 3027 | + | ||
| 3028 | + function getProtoOfProto() { | ||
| 3029 | + return Object.getPrototypeOf(Object.getPrototypeOf(function* () {})); | ||
| 3030 | + } | ||
| 3031 | + | ||
| 3032 | + function* generator() {} | ||
| 3033 | + | ||
| 3034 | + const generatorPrototype = Object.getPrototypeOf(generator); | ||
| 3035 | + const originalProtoOfProto = Object.getPrototypeOf(generatorPrototype); | ||
| 3036 | + assert.strictEqual(getProtoOfProto(), originalProtoOfProto); | ||
| 3037 | + Object.setPrototypeOf(generatorPrototype, null); | ||
| 3038 | + assert.notStrictEqual(getProtoOfProto, originalProtoOfProto); | ||
| 3039 | + | ||
| 3040 | + // This is the actual test. The other assertions in this block are about | ||
| 3041 | + // making sure the test is set up correctly and isn't polluting other tests. | ||
| 3042 | + assert.strictEqual( | ||
| 3043 | + util.inspect(generator, { showHidden: true }), | ||
| 3044 | + '[GeneratorFunction: generator] {\n' + | ||
| 3045 | + ' [length]: 0,\n' + | ||
| 3046 | + " [name]: 'generator',\n" + | ||
| 3047 | + " [prototype]: Object [Generator] { [Symbol(Symbol.toStringTag)]: 'Generator' },\n" + // eslint-disable-line max-len | ||
| 3048 | + " [Symbol(Symbol.toStringTag)]: 'GeneratorFunction'\n" + | ||
| 3049 | + '}' | ||
| 3050 | + ); | ||
| 3051 | + | ||
| 3052 | + // Reset so we don't pollute other tests | ||
| 3053 | + Object.setPrototypeOf(generatorPrototype, originalProtoOfProto); | ||
| 3054 | + assert.strictEqual(getProtoOfProto(), originalProtoOfProto); | ||
| 3055 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments