Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Add test case for #1941.
Browse files Browse the repository at this point in the history
Add test for the false-positives from #1942.
Fix test-sys.js.
  • Loading branch information
TooTallNate authored and koichik committed Oct 26, 2011
1 parent 2dbb470 commit d4379fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 1 addition & 4 deletions test/simple/test-sys.js
Expand Up @@ -37,7 +37,7 @@ assert.equal('Sun, 14 Feb 2010 11:48:40 GMT',
assert.equal("'\\n\\u0001'", common.inspect('\n\u0001'));

assert.equal('[]', common.inspect([]));
assert.equal('[]', common.inspect(Object.create([])));
assert.equal('{}', common.inspect(Object.create([])));

This comment has been minimized.

Copy link
@ry

ry Oct 26, 2011

Why this change?

This comment has been minimized.

Copy link
@TooTallNate

TooTallNate Oct 26, 2011

Author

Object.create() returns an Object.

assert.equal('[ 1, 2 ]', common.inspect([1, 2]));
assert.equal('[ 1, [ 2, 3 ] ]', common.inspect([1, [2, 3]]));

Expand Down Expand Up @@ -91,9 +91,6 @@ assert.equal('{ writeonly: [Setter] }',
var value = {};
value['a'] = value;
assert.equal('{ a: [Circular] }', common.inspect(value));
value = Object.create([]);
value.push(1);
assert.equal('[ 1, length: 1 ]', common.inspect(value));

// Array with dynamic properties
value = [1, 2, 3];
Expand Down
5 changes: 4 additions & 1 deletion test/simple/test-util-inspect.js
Expand Up @@ -53,9 +53,12 @@ try {
assert.equal(util.inspect(e), '[ReferenceError: undef is not defined]');
}
var ex = util.inspect(new Error('FAIL'), true);
console.log(ex);
assert.ok(ex.indexOf('[Error: FAIL]') != -1);
assert.ok(ex.indexOf('[stack]') != -1);
assert.ok(ex.indexOf('[message]') != -1);
assert.ok(ex.indexOf('[arguments]') != -1);
assert.ok(ex.indexOf('[type]') != -1);

// GH-1941
// should not throw:
assert.equal(util.inspect(Object.create(Date.prototype)), '{}')
4 changes: 4 additions & 0 deletions test/simple/test-util.js
Expand Up @@ -36,6 +36,7 @@ assert.equal(false, util.isArray({}))
assert.equal(false, util.isArray({ push: function () {} }))
assert.equal(false, util.isArray(/regexp/))
assert.equal(false, util.isArray(new Error))
assert.equal(false, util.isArray(Object.create(Array.prototype)))

// isRegExp
assert.equal(true, util.isRegExp(/regexp/))
Expand All @@ -45,6 +46,7 @@ assert.equal(true, util.isRegExp(context('RegExp')()))
assert.equal(false, util.isRegExp({}))
assert.equal(false, util.isRegExp([]))
assert.equal(false, util.isRegExp(new Date()))
assert.equal(false, util.isRegExp(Object.create(RegExp.prototype)))

// isDate
assert.equal(true, util.isDate(new Date()))
Expand All @@ -54,6 +56,7 @@ assert.equal(false, util.isDate(Date()))
assert.equal(false, util.isDate({}))
assert.equal(false, util.isDate([]))
assert.equal(false, util.isDate(new Error))
assert.equal(false, util.isDate(Object.create(Date.prototype)))

// isError
assert.equal(true, util.isError(new Error))
Expand All @@ -65,3 +68,4 @@ assert.equal(true, util.isError(new (context('SyntaxError'))))
assert.equal(false, util.isError({}))
assert.equal(false, util.isError({ name: 'Error', message: '' }))
assert.equal(false, util.isError([]))
assert.equal(false, util.isError(Object.create(Error.prototype)))

0 comments on commit d4379fc

Please sign in to comment.