-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Node's built-in test runner works great!
- Loading branch information
Showing
10 changed files
with
288 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,33 @@ | ||
import { test } from 'tap'; | ||
import { test } from 'node:test'; | ||
import { strict as assert } from 'node:assert'; | ||
import * as Diff3 from '../index.mjs'; | ||
|
||
test('LCS', t => { | ||
test('LCS', async t => { | ||
|
||
t.test('returns the LCS of two arrays', t => { | ||
await t.test('returns the LCS of two arrays', t => { | ||
const a = ['AA', 'a', 'b', 'c', 'ZZ', 'new', '00', 'a', 'a', 'M', '99']; | ||
const b = ['AA', 'a', 'd', 'c', 'ZZ', '11', 'M', 'z', 'z', '99']; | ||
const result = Diff3.LCS(a, b); | ||
const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null }; | ||
|
||
t.same(result.buffer1index, 10); // '99' | ||
t.same(result.buffer2index, 9); | ||
assert.deepEqual(result.buffer1index, 10); // '99' | ||
assert.deepEqual(result.buffer2index, 9); | ||
|
||
t.same(result.chain.buffer1index, 9); // 'M' | ||
t.same(result.chain.buffer2index, 6); | ||
assert.deepEqual(result.chain.buffer1index, 9); // 'M' | ||
assert.deepEqual(result.chain.buffer2index, 6); | ||
|
||
t.same(result.chain.chain.buffer1index, 4); // 'ZZ' | ||
t.same(result.chain.chain.buffer2index, 4); | ||
assert.deepEqual(result.chain.chain.buffer1index, 4); // 'ZZ' | ||
assert.deepEqual(result.chain.chain.buffer2index, 4); | ||
|
||
t.same(result.chain.chain.chain.buffer1index, 3); // 'c' | ||
t.same(result.chain.chain.chain.buffer2index, 3); | ||
assert.deepEqual(result.chain.chain.chain.buffer1index, 3); // 'c' | ||
assert.deepEqual(result.chain.chain.chain.buffer2index, 3); | ||
|
||
t.same(result.chain.chain.chain.chain.buffer1index, 1); // 'a' | ||
t.same(result.chain.chain.chain.chain.buffer2index, 1); | ||
assert.deepEqual(result.chain.chain.chain.chain.buffer1index, 1); // 'a' | ||
assert.deepEqual(result.chain.chain.chain.chain.buffer2index, 1); | ||
|
||
t.same(result.chain.chain.chain.chain.chain.buffer1index, 0); // 'AA' | ||
t.same(result.chain.chain.chain.chain.chain.buffer2index, 0); | ||
t.same(result.chain.chain.chain.chain.chain.chain, NULLRESULT); | ||
|
||
t.end(); | ||
assert.deepEqual(result.chain.chain.chain.chain.chain.buffer1index, 0); // 'AA' | ||
assert.deepEqual(result.chain.chain.chain.chain.chain.buffer2index, 0); | ||
assert.deepEqual(result.chain.chain.chain.chain.chain.chain, NULLRESULT); | ||
}); | ||
|
||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,66 @@ | ||
import { test } from 'tap'; | ||
import { test } from 'node:test'; | ||
import { strict as assert } from 'node:assert'; | ||
import * as Diff3 from '../index.mjs'; | ||
|
||
test('diff3MergeRegions', t => { | ||
test('diff3MergeRegions', async t => { | ||
|
||
t.test('returns results of 3-way diff from o,a,b arrays', t => { | ||
await t.test('returns results of 3-way diff from o,a,b arrays', t => { | ||
const o = ['AA', 'ZZ', '00', 'M', '99']; | ||
const a = ['AA', 'a', 'b', 'c', 'ZZ', 'new', '00', 'a', 'a', 'M', '99']; | ||
const b = ['AA', 'a', 'd', 'c', 'ZZ', '11', 'M', 'z', 'z', '99']; | ||
const result = Diff3.diff3MergeRegions(a, o, b); | ||
|
||
t.same(result[0].stable, true); | ||
t.same(result[0].buffer, 'o'); | ||
t.same(result[0].bufferStart, 0); | ||
t.same(result[0].bufferLength, 1); | ||
t.same(result[0].bufferContent, ['AA']); | ||
assert.deepEqual(result[0].stable, true); | ||
assert.deepEqual(result[0].buffer, 'o'); | ||
assert.deepEqual(result[0].bufferStart, 0); | ||
assert.deepEqual(result[0].bufferLength, 1); | ||
assert.deepEqual(result[0].bufferContent, ['AA']); | ||
|
||
t.same(result[1].stable, false); | ||
t.same(result[1].aStart, 1); | ||
t.same(result[1].aLength, 3); | ||
t.same(result[1].aContent, ['a', 'b', 'c']); | ||
t.same(result[1].oStart, 1); | ||
t.same(result[1].oLength, 0); | ||
t.same(result[1].oContent, []); | ||
t.same(result[1].bStart, 1); | ||
t.same(result[1].bLength, 3); | ||
t.same(result[1].bContent, ['a', 'd', 'c']); | ||
assert.deepEqual(result[1].stable, false); | ||
assert.deepEqual(result[1].aStart, 1); | ||
assert.deepEqual(result[1].aLength, 3); | ||
assert.deepEqual(result[1].aContent, ['a', 'b', 'c']); | ||
assert.deepEqual(result[1].oStart, 1); | ||
assert.deepEqual(result[1].oLength, 0); | ||
assert.deepEqual(result[1].oContent, []); | ||
assert.deepEqual(result[1].bStart, 1); | ||
assert.deepEqual(result[1].bLength, 3); | ||
assert.deepEqual(result[1].bContent, ['a', 'd', 'c']); | ||
|
||
t.same(result[2].stable, true); | ||
t.same(result[2].buffer, 'o'); | ||
t.same(result[2].bufferStart, 1); | ||
t.same(result[2].bufferLength, 1); | ||
t.same(result[2].bufferContent, ['ZZ']); | ||
assert.deepEqual(result[2].stable, true); | ||
assert.deepEqual(result[2].buffer, 'o'); | ||
assert.deepEqual(result[2].bufferStart, 1); | ||
assert.deepEqual(result[2].bufferLength, 1); | ||
assert.deepEqual(result[2].bufferContent, ['ZZ']); | ||
|
||
t.same(result[3].stable, false); | ||
t.same(result[3].aStart, 5); | ||
t.same(result[3].aLength, 4); | ||
t.same(result[3].aContent, ['new', '00', 'a', 'a']); | ||
t.same(result[3].oStart, 2); | ||
t.same(result[3].oLength, 1); | ||
t.same(result[3].oContent, ['00']); | ||
t.same(result[3].bStart, 5); | ||
t.same(result[3].bLength, 1); | ||
t.same(result[3].bContent, ['11']); | ||
assert.deepEqual(result[3].stable, false); | ||
assert.deepEqual(result[3].aStart, 5); | ||
assert.deepEqual(result[3].aLength, 4); | ||
assert.deepEqual(result[3].aContent, ['new', '00', 'a', 'a']); | ||
assert.deepEqual(result[3].oStart, 2); | ||
assert.deepEqual(result[3].oLength, 1); | ||
assert.deepEqual(result[3].oContent, ['00']); | ||
assert.deepEqual(result[3].bStart, 5); | ||
assert.deepEqual(result[3].bLength, 1); | ||
assert.deepEqual(result[3].bContent, ['11']); | ||
|
||
t.same(result[4].stable, true); | ||
t.same(result[4].buffer, 'o'); | ||
t.same(result[4].bufferStart, 3); | ||
t.same(result[4].bufferLength, 1); | ||
t.same(result[4].bufferContent, ['M']); | ||
assert.deepEqual(result[4].stable, true); | ||
assert.deepEqual(result[4].buffer, 'o'); | ||
assert.deepEqual(result[4].bufferStart, 3); | ||
assert.deepEqual(result[4].bufferLength, 1); | ||
assert.deepEqual(result[4].bufferContent, ['M']); | ||
|
||
t.same(result[5].stable, true); | ||
t.same(result[5].buffer, 'b'); | ||
t.same(result[5].bufferStart, 7); | ||
t.same(result[5].bufferLength, 2); | ||
t.same(result[5].bufferContent, ['z', 'z']); | ||
assert.deepEqual(result[5].stable, true); | ||
assert.deepEqual(result[5].buffer, 'b'); | ||
assert.deepEqual(result[5].bufferStart, 7); | ||
assert.deepEqual(result[5].bufferLength, 2); | ||
assert.deepEqual(result[5].bufferContent, ['z', 'z']); | ||
|
||
t.same(result[6].stable, true); | ||
t.same(result[6].buffer, 'o'); | ||
t.same(result[6].bufferStart, 4); | ||
t.same(result[6].bufferLength, 1); | ||
t.same(result[6].bufferContent, ['99']); | ||
|
||
t.end(); | ||
assert.deepEqual(result[6].stable, true); | ||
assert.deepEqual(result[6].buffer, 'o'); | ||
assert.deepEqual(result[6].bufferStart, 4); | ||
assert.deepEqual(result[6].bufferLength, 1); | ||
assert.deepEqual(result[6].bufferContent, ['99']); | ||
}); | ||
|
||
t.end(); | ||
}); |
Oops, something went wrong.