Skip to content

Commit

Permalink
Explicitly check for empty Array instead of comparing to []
Browse files Browse the repository at this point in the history
  • Loading branch information
mranney committed Nov 30, 2010
1 parent 2750301 commit f30e082
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test.js
Expand Up @@ -74,6 +74,10 @@ function require_error(label) {
};
}

function is_empty_array(obj) {
return Array.isArray(obj) && obj.length === 0;
}

function last(name, fn) {
return function (err, results) {
fn(err, results);
Expand Down Expand Up @@ -160,7 +164,7 @@ tests.MULTI_3 = function () {
])
.scard("some set")
.exec(function (err, replies) {
assert.deepEqual(replies[2][0], [], name);
assert.strictEqual(true, is_empty_array(replies[2][0]), name);
next(name);
});
};
Expand Down Expand Up @@ -366,7 +370,7 @@ tests.MULTIBULK_ZERO_LENGTH = function () {
var name = "MULTIBULK_ZERO_LENGTH";
client.KEYS(['users:*'], function (err, results) {
assert.strictEqual(null, err, 'error on empty multibulk reply');
assert.deepEqual([], results);
assert.strictEqual(true, is_empty_array(results), "not an empty array");
next(name);
});
};
Expand Down

0 comments on commit f30e082

Please sign in to comment.