| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2576,7 +2576,7 @@ function formatProperty(ctx, value, recurseTimes, key, type, desc, | |||
| 2576 | 2576 | const tmp = FunctionPrototypeCall(desc.get, original); | |
| 2577 | 2577 | if (tmp === null) { | |
| 2578 | 2578 | str = `${s(`[${label}:`, sp)} ${s('null', 'null')}${s(']', sp)}`; | |
| 2579 | - } else if (typeof tmp === 'object') { | ||
| 2579 | + } else if (typeof tmp === 'object' || typeof tmp === 'function') { | ||
| 2580 | 2580 | str = `${s(`[${label}]`, sp)} ${formatValue(ctx, tmp, recurseTimes)}`; | |
| 2581 | 2581 | } else { | |
| 2582 | 2582 | const primitive = formatPrimitive(s, tmp, ctx); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2596,6 +2596,15 @@ assert.strictEqual( | |||
| 2596 | 2596 | "'foobar', { x: 1 } },\n inc: [Getter: NaN]\n}"); | |
| 2597 | 2597 | } | |
| 2598 | 2598 | ||
| 2599 | + // Getter returning a function. | ||
| 2600 | + // https://github.com/nodejs/node/issues/64838 | ||
| 2601 | + { | ||
| 2602 | + const obj = { get foo() { return function bar() {}; } }; | ||
| 2603 | + assert.strictEqual( | ||
| 2604 | + inspect(obj, { getters: true }), | ||
| 2605 | + '{ foo: [Getter] [Function: bar] }'); | ||
| 2606 | + } | ||
| 2607 | + | ||
| 2599 | 2608 | // Property getter throwing an error. | |
| 2600 | 2609 | { | |
| 2601 | 2610 | const error = new Error('Oops'); | |
@@ -3524,16 +3533,14 @@ assert.strictEqual( | |||
| 3524 | 3533 | '\x1B[2mdef: \x1B[33m5\x1B[39m\x1B[22m }' | |
| 3525 | 3534 | ); | |
| 3526 | 3535 | ||
| 3527 | - assert.match( | ||
| 3536 | + assert.strictEqual( | ||
| 3528 | 3537 | inspect(Object.getPrototypeOf(bar), { showHidden: true, getters: true }), | |
| 3529 | - new RegExp('^' + RegExp.escape( | ||
| 3530 | - '<ref *1> Foo [Map] {\n' + | ||
| 3531 | - ' [constructor]: [class Bar extends Foo] {\n' + | ||
| 3538 | + '<ref *2> Foo [Map] {\n' + | ||
| 3539 | + ' [constructor]: <ref *1> [class Bar extends Foo] {\n' + | ||
| 3532 | 3540 | ' [length]: 0,\n' + | |
| 3533 | 3541 | " [name]: 'Bar',\n" + | |
| 3534 | - ' [prototype]: [Circular *1],\n' + | ||
| 3535 | - ' [Symbol(Symbol.species)]: [Getter: <Inspection threw ' + | ||
| 3536 | - "(TypeError: Symbol.prototype.toString requires that 'this' be a Symbol") + '.*' + RegExp.escape(')>]\n' + | ||
| 3542 | + ' [prototype]: [Circular *2],\n' + | ||
| 3543 | + ' [Symbol(Symbol.species)]: [Getter] [Circular *1]\n' + | ||
| 3537 | 3544 | ' },\n' + | |
| 3538 | 3545 | " [xyz]: [Getter: 'YES!'],\n" + | |
| 3539 | 3546 | ' [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] {\n' + | |
@@ -3543,7 +3550,6 @@ assert.strictEqual( | |||
| 3543 | 3550 | ' [abc]: [Getter: true],\n' + | |
| 3544 | 3551 | ' [def]: [Getter/Setter: false]\n' + | |
| 3545 | 3552 | '}' | |
| 3546 | - ) + '$', 's') | ||
| 3547 | 3553 | ); | |
| 3548 | 3554 | ||
| 3549 | 3555 | assert.strictEqual( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments