diff --git a/lib/util.js b/lib/util.js index aafc0edf32..b00da2de9d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -155,7 +155,7 @@ function formatValue(ctx, value, recurseTimes) { // Check that value is an object with an inspect function on it if (value && typeof value.inspect === 'function' && // Filter out the util module, it's inspect function is special - value !== exports && + value.inspect !== exports.inspect && // Also filter out any prototype objects using the circular check. !(value.constructor && value.constructor.prototype === value)) { return value.inspect(recurseTimes); diff --git a/test/simple/test-util-inspect.js b/test/simple/test-util-inspect.js index 68fea328cc..c7a64f6390 100644 --- a/test/simple/test-util-inspect.js +++ b/test/simple/test-util-inspect.js @@ -75,3 +75,7 @@ assert.doesNotThrow(function () { r.toString = null; util.inspect(r); }); + +// GH-2225 +var x = { inspect: util.inspect }; +assert.ok(util.inspect(x).indexOf('inspect') != -1);