Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add test case for #1941.

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 d4379fcee3b7d7838caf21bddca5248c33f8771f
Showing with 9 additions and 5 deletions.
  1. +1 −4 test/simple/test-sys.js
  2. +4 −1 test/simple/test-util-inspect.js
  3. +4 −0 test/simple/test-util.js
@@ -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]]));

@@ -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];
@@ -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)), '{}')
@@ -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/))
@@ -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()))
@@ -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))
@@ -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.
You can’t perform that action at this time.