GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: check null proto-of-proto in util.inspect() · nodejs/node@fee0389

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test/parallel
    • test-util-inspect.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+32Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,3 +3021,35 @@ assert.strictEqual(
30213021
'}'
30223022
);
30233023
}
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+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.