Permalink
Browse files

Dissimilarity test of null vs. an object must pass

  • Loading branch information...
1 parent a62c7ab commit 182d14427d2388bc9539cea85568f9702033587a @jhs jhs committed with isaacs Dec 5, 2011
Showing with 5 additions and 3 deletions.
  1. +2 −1 lib/tap-assert.js
  2. +3 −2 test/meta-test.js
View
3 lib/tap-assert.js
@@ -239,7 +239,8 @@ function dissimilar (a, b, message, extra) {
if (extra && extra.skip) return assert.skip(message, extra)
// test that a has all the fields in b
message = message || "should be dissimilar"
- return inequivalent(selectFields(a, b), b, message, extra)
+ a = a && selectFields(a, b); // Always send selectFields() usable params.
+ return inequivalent(a, b, message, extra)
}
assert.dissimilar = dissimilar
syns.dissimilar = ["unsimilar"
View
5 test/meta-test.js
@@ -24,6 +24,7 @@ test("meta test", { skip: false }, function (t) {
t.doesNotThrow(noop, "noop does not throw");
t.similar({foo:"bar", bar:"foo"}, {foo:"bar"}, "similar objects are ok");
t.dissimilar({}, {mandatory:"value"}, "dissimilar objects are ok");
+ t.dissimilar(null, {}, "null is dissimilar from an object, even with no keys");
// a few failures.
t.ifError(new Error("this is an error"))
@@ -42,8 +43,8 @@ test("meta test", { skip: false }, function (t) {
t.clear()
t.ok(true, "sanity check")
t.notOk(results.ok, "not ok")
- t.equal(results.tests, 25, "total test count")
- t.equal(results.passTotal, 16, "tests passed")
+ t.equal(results.tests, 26, "total test count")
+ t.equal(results.passTotal, 17, "tests passed")
t.equal(results.fail, 9, "tests failed")
t.type(results.ok, "boolean", "ok is boolean")
t.type(results.skip, "number", "skip is number")

0 comments on commit 182d144

Please sign in to comment.