Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
sys.inspect prints out special chars correctly (\n, \u0001, etc...)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviershay authored and ry committed Dec 7, 2009
1 parent c3e0a4b commit 756544f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sys.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ exports.inherits = process.inherits;
*/
var formatter = function(value, indent, parents) {
switch(typeof(value)) {
case 'string': return '"' + value + '"';
case 'string': return JSON.stringify(value);
case 'number': return '' + value;
case 'function': return '[Function]';
case 'boolean': return '' + value;
Expand Down
2 changes: 2 additions & 0 deletions test/mjsunit/test-sys.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ assert.equal("[Function]", inspect(function() {}));
assert.equal('undefined', inspect(undefined));
assert.equal('null', inspect(null));

assert.equal("\"\\n\\u0001\"", inspect("\n\u0001"));

assert.equal('[]', inspect([]));
assert.equal('[\n 1,\n 2\n]', inspect([1, 2]));
assert.equal('[\n 1,\n [\n 2,\n 3\n ]\n]', inspect([1, [2, 3]]));
Expand Down

0 comments on commit 756544f

Please sign in to comment.