@@ -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 ;
@@ -3425,6 +3425,34 @@ ${error.stack.split('\n').slice(1).join('\n')}`,
34253425
34263426 assert . strictEqual (
34273427 inspect ( error ) ,
3428- '[[\n Symbol(foo)\n]]'
3428+ '[Error\n [\n Symbol(foo)\n ]]'
34293429 ) ;
34303430}
3431+
3432+ {
3433+ const prepareStackTrace = Error . prepareStackTrace ;
3434+
3435+ Error . prepareStackTrace = ( error ) => error ;
3436+
3437+ const error = new Error ( 'foo' ) ;
3438+
3439+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3440+
3441+ Error . prepareStackTrace = prepareStackTrace ;
3442+ }
3443+
3444+ {
3445+ const error = new Error ( 'foo' ) ;
3446+ error . stack = error ;
3447+
3448+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Circular *1]]' ) ;
3449+ }
3450+
3451+ {
3452+ const error = new Error ( 'foo' ) ;
3453+ const error2 = new Error ( 'bar' ) ;
3454+ error . stack = error2 ;
3455+ error2 . stack = error ;
3456+
3457+ assert . strictEqual ( inspect ( error ) , '[Error: foo\n [Error: bar\n [Circular *1]]]' ) ;
3458+ }
0 commit comments