Permalink
Browse files

passing buffer comparison test using buffer-equal

  • Loading branch information...
1 parent c972ae8 commit 68c98260670d8f2514667abc1e6fc251d2507395 @substack committed May 11, 2012
Showing with 16 additions and 3 deletions.
  1. +14 −2 lib/tap-assert.js
  2. +2 −1 package.json
View
@@ -1,6 +1,7 @@
// an assert module that returns tappable data for each assertion.
var difflet = require('difflet')
, deepEqual = require('deep-equal')
+ , bufferEqual = require('buffer-equal')
module.exports = assert
@@ -173,7 +174,12 @@ function equivalent (a, b, message, extra) {
message = message || "should be equivalent"
extra.found = a
extra.wanted = b
- return assert(deepEqual(a, b), message, extra)
+
+ if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) {
+ return assert(bufferEqual(a, b), message, extra)
+ } else {
+ return assert(deepEqual(a, b), message, extra)
+ }
}
assert.equivalent = equivalent
syns.equivalent = ["isEquivalent"
@@ -209,12 +215,18 @@ function inequivalent (a, b, message, extra) {
message = message || "should not be equivalent"
extra.found = a
extra.doNotWant = b
- return assert(!deepEqual(a, b), message, extra)
+
+ if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) {
+ return assert(!bufferEqual(a, b), message, extra)
+ } else {
+ return assert(!deepEqual(a, b), message, extra)
+ }
}
assert.inequivalent = inequivalent
syns.inequivalent = ["notEquivalent"
,"notDeepEqual"
,"notDeeply"
+ ,"notSame"
,"isNotDeepEqual"
,"isNotDeeply"
,"isNotEquivalent"
View
@@ -13,7 +13,8 @@
"nopt": "~1.0.10",
"mkdirp": "~0.3",
"difflet" : "~0.2.0",
- "deep-equal" : "~0.0.0"
+ "deep-equal" : "~0.0.0",
+ "buffer-equal" : "~0.0.0"
},
"bundledDependencies": [
"inherits",

0 comments on commit 68c9826

Please sign in to comment.