Closes GH-310 Format slashes properly
This commit is contained in:
parent
a7254f3df9
commit
4d64f36338
@ -118,9 +118,9 @@ exports.inspect = function(obj, showHidden, depth, colors) {
|
||||
return stylize('undefined', 'undefined');
|
||||
|
||||
case 'string':
|
||||
var simple = JSON.stringify(value).replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/(^"|"$)/g, "'");
|
||||
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||||
.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"') + '\'';
|
||||
return stylize(simple, 'string');
|
||||
|
||||
case 'number':
|
||||
|
@ -31,11 +31,12 @@ global.process.stdout.write = function(string) {
|
||||
console.log('foo');
|
||||
console.log('foo', 'bar');
|
||||
console.log('%s %s', 'foo', 'bar', 'hop');
|
||||
console.log({slashes: '\\\\'})
|
||||
|
||||
global.process.stdout.write = stdout_write;
|
||||
assert.equal('foo\n', strings.shift());
|
||||
assert.equal('foo bar\n', strings.shift());
|
||||
assert.equal('foo bar hop\n', strings.shift());
|
||||
|
||||
assert.equal("{ slashes: '\\\\\\\\' }\n", strings.shift());
|
||||
|
||||
assert.equal(true, process.stderr.write("hello world"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user