@@ -770,14 +770,14 @@ assert.strictEqual(util.inspect(-5e-324), '-5e-324');
770770// Note: Symbols are not supported by `Error#toString()` which is called by
771771// accessing the `stack` property.
772772[
773- [ 404 , '404 [RangeError]: foo' , '[404]' ] ,
773+ [ 404 , '404 [RangeError]: foo' , '[RangeError: foo\n 404]' ] ,
774774 [ 0 , '0 [RangeError]: foo' , '[RangeError: foo]' ] ,
775775 [ 0n , '0 [RangeError]: foo' , '[RangeError: foo]' ] ,
776776 [ null , 'null: foo' , '[RangeError: foo]' ] ,
777777 [ undefined , 'RangeError: foo' , '[RangeError: foo]' ] ,
778778 [ false , 'false [RangeError]: foo' , '[RangeError: foo]' ] ,
779779 [ '' , 'foo' , '[RangeError: foo]' ] ,
780- [ [ 1 , 2 , 3 ] , '1,2,3 [RangeError]: foo' , '[[\n 1,\n 2,\n 3\n]]' ] ,
780+ [ [ 1 , 2 , 3 ] , '1,2,3 [RangeError]: foo' , '[RangeError: foo\n [\n 1,\n 2,\n 3\n ]]' ] ,
781781] . forEach ( ( [ value , outputStart , stack ] ) => {
782782 let err = new RangeError ( 'foo' ) ;
783783 err . name = value ;
@@ -3457,6 +3457,34 @@ ${error.stack.split('\n').slice(1).join('\n')}`,
34573457
34583458 assert . strictEqual (
34593459 inspect ( error ) ,
3460- '[[\n Symbol(foo)\n]]'
3460+ '[Error\n [\n Symbol(foo)\n ]]'
34613461 ) ;
34623462}
3463+
3464+ {
3465+ const prepareStackTrace = Error . prepareStackTrace ;
3466+
3467+ Error . prepareStackTrace = ( error ) => error ;
3468+
3469+ const error = new Error ( 'foo' ) ;
3470+
3471+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3472+
3473+ Error . prepareStackTrace = prepareStackTrace ;
3474+ }
3475+
3476+ {
3477+ const error = new Error ( 'foo' ) ;
3478+ error . stack = error ;
3479+
3480+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3481+ }
3482+
3483+ {
3484+ const error = new Error ( 'foo' ) ;
3485+ const error2 = new Error ( 'bar' ) ;
3486+ error . stack = error2 ;
3487+ error2 . stack = error ;
3488+
3489+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Error: bar\n [Circular *1]]]' ) ;
3490+ }
0 commit comments