Show inherited properties when inspecting an object.

This commit is contained in:
Domenic Denicola 2012-12-30 06:25:17 -05:00
parent fe45a2d667
commit 730a12baa6
3 changed files with 7 additions and 5 deletions

View file

@ -2,6 +2,8 @@
// https://github.com/joyent/node/blob/f8c335d0caf47f16d31413f89aa28eda3878e3aa/lib/util.js
var getName = require('./getName');
var getProperties = require('./getProperties');
var getEnumerableProperties = require('./getEnumerableProperties');
module.exports = inspect;
@ -78,8 +80,8 @@ function formatValue(ctx, value, recurseTimes) {
}
// Look up the keys of the object.
var visibleKeys = Object.keys(value);
var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
var visibleKeys = getEnumerableProperties(value);
var keys = ctx.showHidden ? getProperties(value) : visibleKeys;
// Some type of object without properties can be shortcutted.
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,

View file

@ -336,7 +336,7 @@ suite('expect', function () {
err(function(){
expect(new FakeArgs).not.to.be.empty;
}, "expected {} not to be empty");
}, "expected { length: 0 } not to be empty");
err(function(){
expect({arguments: 0}).to.be.empty;

View file

@ -320,7 +320,7 @@ suite('should', function() {
err(function(){
(new FakeArgs).should.not.be.empty;
}, "expected {} not to be empty");
}, "expected { length: 0 } not to be empty");
err(function(){
({arguments: 0}).should.be.empty;