Permalink
Browse files

Add test case for custom inspect() functionality.

  • Loading branch information...
1 parent cb757e3 commit 86810e3609f4edd74423d50cfb2d8c45c482d1d2 @TooTallNate committed Dec 30, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 test/simple/test-util-inspect.js
@@ -79,3 +79,16 @@ assert.doesNotThrow(function () {
// GH-2225
var x = { inspect: util.inspect };
assert.ok(util.inspect(x).indexOf('inspect') != -1);
+
+// test for custom inspect() functionality
+var o = { foo: 'bar' };
+var inspectCalled = false;
+o.inspect = function (d, h, c) {
+ inspectCalled = true;
+ assert.equal(d, 10);
+ assert.equal(h, false);
+ assert.equal(c, true);
+ return this.foo;
+}
+assert.equal(util.inspect(o, false, 10, true), 'bar');
+assert.ok(inspectCalled);

0 comments on commit 86810e3

Please sign in to comment.