better printing of actual/expected buffers in error for visual compare

This commit is contained in:
Brian Carlson 2011-01-14 15:18:56 -06:00
parent fd1dd95b43
commit 9a08f51a72

View File

@ -64,18 +64,21 @@ assert.UTCDate = function(actual, year, month, day, hours, min, sec, milisecond)
assert.equal(actualMili, milisecond, "expected milisecond " + milisecond + " but got " + actualMili);
};
var spit = function(actual, expected) {
console.log("");
console.log("actual " + sys.inspect(actual));
console.log("expect " + sys.inspect(expected));
console.log("");
}
assert.equalBuffers = function(actual, expected) {
if(actual.length != expected.length) {
console.log("");
console.log("actual " + sys.inspect(actual));
console.log("expect " + sys.inspect(expected));
console.log("");
spit(actual, expected)
assert.equal(actual.length, expected.length);
}
for(var i = 0; i < actual.length; i++) {
if(actual[i] != expected[i]) {
console.log(actual);
console.log(expected);
spit(actual, expected)
}
assert.equal(actual[i],expected[i]);
}