@@ -838,22 +838,22 @@ if (typeof Symbol !== 'undefined') {
838
838
const options = { showHidden : true } ;
839
839
let subject = { } ;
840
840
841
- subject [ Symbol ( 'symbol ' ) ] = 42 ;
841
+ subject [ Symbol ( 'sym\nbol ' ) ] = 42 ;
842
842
843
- assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(symbol )]: 42 }' ) ;
843
+ assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(sym\\nbol )]: 42 }' ) ;
844
844
assert . strictEqual (
845
845
util . inspect ( subject , options ) ,
846
- '{ [Symbol(symbol )]: 42 }'
846
+ '{ [Symbol(sym\\nbol )]: 42 }'
847
847
) ;
848
848
849
849
Object . defineProperty (
850
850
subject ,
851
851
Symbol ( ) ,
852
852
{ enumerable : false , value : 'non-enum' } ) ;
853
- assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(symbol )]: 42 }' ) ;
853
+ assert . strictEqual ( util . inspect ( subject ) , '{ [Symbol(sym\\nbol )]: 42 }' ) ;
854
854
assert . strictEqual (
855
855
util . inspect ( subject , options ) ,
856
- "{ [Symbol(symbol )]: 42, [Symbol()]: 'non-enum' }"
856
+ "{ [Symbol(sym\\nbol )]: 42, [Symbol()]: 'non-enum' }"
857
857
) ;
858
858
859
859
subject = [ 1 , 2 , 3 ] ;
@@ -1637,3 +1637,13 @@ assert.strictEqual(inspect(Object(-1n)), '[BigInt: -1n]');
1637
1637
assert . strictEqual ( inspect ( Object ( 13n ) ) , '[BigInt: 13n]' ) ;
1638
1638
assert . strictEqual ( inspect ( new BigInt64Array ( [ 0n ] ) ) , 'BigInt64Array [ 0n ]' ) ;
1639
1639
assert . 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