Closes GH-310 Format slashes properly

This commit is contained in:
isaacs 2011-03-29 14:41:23 -07:00 committed by Ryan Dahl
parent a7254f3df9
commit 4d64f36338
2 changed files with 5 additions and 4 deletions

View File

@ -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':

View File

@ -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"));