diff options
author | buji <zheyuzhang03@gmail.com> | 2017-11-13 19:44:16 +0800 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-11-18 20:52:08 +0100 |
commit | 71ee0d9a40c5360eb322fcaa1c2b0145f8c2d2a8 (patch) | |
tree | dbec4cbb5cb3390fa17247936551bd1b27cfa1fa /test | |
parent | 95d9a58cbc13761087180c85c042b2e9cf1595e9 (diff) | |
download | android-node-v8-71ee0d9a40c5360eb322fcaa1c2b0145f8c2d2a8.tar.gz android-node-v8-71ee0d9a40c5360eb322fcaa1c2b0145f8c2d2a8.tar.bz2 android-node-v8-71ee0d9a40c5360eb322fcaa1c2b0145f8c2d2a8.zip |
util: escaping object keys in util.inspect()
PR-URL: https://github.com/nodejs/node/pull/16986
Fixes: https://github.com/nodejs/node/issues/16979
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-util-inspect.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index edd097ee7a..58e06cb0b6 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -566,25 +566,31 @@ assert.doesNotThrow(() => { assert.strictEqual(util.inspect(x).includes('inspect'), true); } -// util.inspect should not display the escaped value of a key. +// util.inspect should display the escaped value of a key. { const w = { '\\': 1, '\\\\': 2, '\\\\\\': 3, '\\\\\\\\': 4, + '\n': 5, + '\r': 6 }; const y = ['a', 'b', 'c']; - y['\\\\\\'] = 'd'; + y['\\\\'] = 'd'; + y['\n'] = 'e'; + y['\r'] = 'f'; assert.strictEqual( util.inspect(w), - '{ \'\\\': 1, \'\\\\\': 2, \'\\\\\\\': 3, \'\\\\\\\\\': 4 }' + '{ \'\\\\\': 1, \'\\\\\\\\\': 2, \'\\\\\\\\\\\\\': 3, ' + + '\'\\\\\\\\\\\\\\\\\': 4, \'\\n\': 5, \'\\r\': 6 }' ); assert.strictEqual( util.inspect(y), - '[ \'a\', \'b\', \'c\', \'\\\\\\\': \'d\' ]' + '[ \'a\', \'b\', \'c\', \'\\\\\\\\\': \'d\', ' + + '\'\\n\': \'e\', \'\\r\': \'f\' ]' ); } |