dtl
Version:
A diff template library binding for node.js
54 lines (45 loc) • 936 B
JavaScript
var dtl = require('dtl');
var diff = new dtl.Diff("abc", "abd");
diff.compose();
diff.composeUnifiedHunks();
var correct_lcs = "ab";
var correct_ses = [
{ ' ' : 'a' },
{ ' ' : 'b' },
{ '-' : 'c' },
{ '+' : 'd' }
];
var correct_unihunks = [
{
a: 1,
b: 3,
c: 1,
d: 3,
diff: [
{ ' ': 'a' },
{ ' ': 'b' },
{ '-': 'c' },
{ '+': 'd' }
]
}
]
exports['editdistance'] =
function (test) {
test.equal(diff.editdistance(), 2);
test.done();
};
exports['lcs'] =
function (test) {
test.equal(diff.lcs(), correct_lcs);
test.done();
};
exports['ses'] =
function (test) {
test.deepEqual(correct_ses, diff.ses());
test.done();
};
exports['unihunks'] =
function (test) {
test.deepEqual(correct_unihunks, diff.uniHunks());
test.done();
};