@@ -690,7 +690,7 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
690690
691691{
692692 const tmp = Error . stackTraceLimit ;
693- Error . stackTraceLimit = 0 ;
693+ Object . defineProperty ( Error , ' stackTraceLimit' , { value : 0 , enumerable : false } ) ;
694694 const err = new Error ( 'foo' ) ;
695695 const err2 = new Error ( 'foo\nbar' ) ;
696696 assert . strictEqual ( util . inspect ( err , { compact : true } ) , '[Error: foo]' ) ;
@@ -2586,6 +2586,7 @@ assert.strictEqual(
25862586
25872587 Object . defineProperties ( error , {
25882588 name : throwingGetter ,
2589+ message : throwingGetter ,
25892590 stack : throwingGetter ,
25902591 cause : throwingGetter ,
25912592 } ) ;
@@ -2600,6 +2601,7 @@ assert.strictEqual(
26002601 ' foo: [Getter: <Inspection threw ([object Error] {\n' +
26012602 ' stack: [Getter/Setter],\n' +
26022603 ' name: [Getter],\n' +
2604+ ' message: [Getter],\n' +
26032605 ' cause: [Getter]\n' +
26042606 '})>]\n' +
26052607 '}' ,
@@ -2654,9 +2656,7 @@ assert.strictEqual(
26542656 inspect ( {
26552657 get foo ( ) { throw Error ; }
26562658 } , { getters : true } ) ,
2657- '{\n' +
2658- ' foo: [Getter: <Inspection threw ([Function: Error] { stackTraceLimit: 0 })>]\n' +
2659- '}'
2659+ '{ foo: [Getter: <Inspection threw ([Function: Error])>] }'
26602660 ) ;
26612661}
26622662
@@ -3341,36 +3341,26 @@ assert.strictEqual(
33413341 '\x1B[2mdef: \x1B[33m5\x1B[39m\x1B[22m }'
33423342 ) ;
33433343
3344- assert . strictEqual (
3344+ assert . match (
33453345 inspect ( Object . getPrototypeOf ( bar ) , { showHidden : true , getters : true } ) ,
3346- '<ref *1> Foo [Map] {\n' +
3347- ' [constructor]: [class Bar extends Foo] {\n' +
3348- ' [length]: 0,\n' +
3349- " [name]: 'Bar',\n" +
3350- ' [prototype]: [Circular *1],\n' +
3351- ' [Symbol(Symbol.species)]: [Getter: <Inspection threw ' +
3352- // Heh? I don't know how to override the error stack to make it predictable
3353- "(TypeError: Symbol.prototype.toString requires that 'this' be a Symbol\n" +
3354- ' at Bar.toString (<anonymous>)\n' +
3355- ' at formatPrimitive (node:internal/util/inspect:2246:13)\n' +
3356- ' at formatProperty (node:internal/util/inspect:2556:29)\n' +
3357- ' at addPrototypeProperties (node:internal/util/inspect:1010:21)\n' +
3358- ' at getConstructorName (node:internal/util/inspect:918:11)\n' +
3359- ' at formatRaw (node:internal/util/inspect:1194:23)\n' +
3360- ' at formatValue (node:internal/util/inspect:1184:10)\n' +
3361- ' at formatProperty (node:internal/util/inspect:2536:11)\n' +
3362- ' at formatRaw (node:internal/util/inspect:1429:9)\n' +
3363- ' at formatValue (node:internal/util/inspect:1184:10))>]\n' +
3364- ' },\n' +
3365- " [xyz]: [Getter: 'YES!'],\n" +
3366- ' [Symbol(nodejs.util.inspect.custom)]: ' +
3367- '[Function: [nodejs.util.inspect.custom]] {\n' +
3368- ' [length]: 0,\n' +
3369- " [name]: '[nodejs.util.inspect.custom]'\n" +
3370- ' },\n' +
3371- ' [abc]: [Getter: true],\n' +
3372- ' [def]: [Getter/Setter: false]\n' +
3373- ' }'
3346+ new RegExp ( '^' + RegExp . escape (
3347+ '<ref *1> Foo [Map] {\n' +
3348+ ' [constructor]: [class Bar extends Foo] {\n' +
3349+ ' [length]: 0,\n' +
3350+ " [name]: 'Bar',\n" +
3351+ ' [prototype]: [Circular *1],\n' +
3352+ ' [Symbol(Symbol.species)]: [Getter: <Inspection threw ' +
3353+ "(TypeError: Symbol.prototype.toString requires that 'this' be a Symbol" ) + '.*' + RegExp . escape ( ')>]\n' +
3354+ ' },\n' +
3355+ " [xyz]: [Getter: 'YES!'],\n" +
3356+ ' [Symbol(nodejs.util.inspect.custom)]: [Function: [nodejs.util.inspect.custom]] {\n' +
3357+ ' [length]: 0,\n' +
3358+ " [name]: '[nodejs.util.inspect.custom]'\n" +
3359+ ' },\n' +
3360+ ' [abc]: [Getter: true],\n' +
3361+ ' [def]: [Getter/Setter: false]\n' +
3362+ ' }'
3363+ ) + '$' , 's' )
33743364 ) ;
33753365
33763366 assert . strictEqual (
0 commit comments