@@ -838,22 +838,22 @@ if (typeof Symbol !== 'undefined') {
838838 const options = { showHidden : true } ;
839839 let subject = { } ;
840840
841- subject [ Symbol ( 'symbol ' ) ] = 42 ;
841+ subject [ Symbol ( 'sym\nbol ' ) ] = 42 ;
842842
843- assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(symbol )]: 42 }' ) ;
843+ assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(sym\\nbol )]: 42 }' ) ;
844844 assert . strictEqual (
845845 util . inspect ( subject , options ) ,
846- '{ [Symbol(symbol )]: 42 }'
846+ '{ [Symbol(sym\\nbol )]: 42 }'
847847 ) ;
848848
849849 Object . defineProperty (
850850 subject ,
851851 Symbol ( ) ,
852852 { enumerable : false , value : 'non-enum' } ) ;
853- assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(symbol )]: 42 }' ) ;
853+ assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(sym\\nbol )]: 42 }' ) ;
854854 assert . strictEqual (
855855 util . inspect ( subject , options ) ,
856- "{ [Symbol(symbol )]: 42, [Symbol()]: 'non-enum' }"
856+ "{ [Symbol(sym\\nbol )]: 42, [Symbol()]: 'non-enum' }"
857857 ) ;
858858
859859 subject = [ 1 , 2 , 3 ] ;
@@ -1637,3 +1637,13 @@ assert.strictEqual(inspect(Object(-1n)), '[BigInt: -1n]');
16371637assert . strictEqual ( inspect ( Object ( 13n ) ) , '[BigInt: 13n]' ) ;
16381638assert . strictEqual ( inspect ( new BigInt64Array ( [ 0n ] ) ) , 'BigInt64Array [ 0n ]' ) ;
16391639assert . strictEqual ( inspect ( new BigUint64Array ( [ 0n ] ) ) , 'BigUint64Array [ 0n ]' ) ;
1640+
1641+ // Verify non-enumerable keys get escaped.
1642+ {
1643+ const obj = { } ;
1644+ Object . defineProperty ( obj , 'Non\nenumerable\tkey' , { value : true } ) ;
1645+ assert . strictEqual (
1646+ util . inspect ( obj , { showHidden : true } ) ,
1647+ '{ [Non\\nenumerable\\tkey]: true }'
1648+ ) ;
1649+ }
0 commit comments