Skip to content

Commit

Permalink
Tidy and complete tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mesmo committed Jul 7, 2017
1 parent 022ffcc commit 1ffd620
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
9 changes: 9 additions & 0 deletions lib/node/index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/**
* @module graph
*
* A small library of graph algorithms.
*
* @copyright (c) 2017 David Mesquita-Morris
*
* Licensed under the MIT and GPL v3 licences
*/
export { Tree } from "./tree";
10 changes: 10 additions & 0 deletions lib/node/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
"use strict";
/**
* @module graph
*
* A small library of graph algorithms.
*
* @copyright (c) 2017 David Mesquita-Morris
*
* Licensed under the MIT and GPL v3 licences
*/
Object.defineProperty(exports, "__esModule", { value: true });
// pull in the tree algorithms
var tree_1 = require("./tree");
exports.Tree = tree_1.Tree;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@steelbreeze/graph",
"version": "1.0.1",
"version": "1.0.2",
"description": "Graph libraries for TypeScript and JavaScript",
"main": "./lib/node/index.js",
"typings": "./lib/node/index.d.ts",
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
/**
* @module graph
*
* A small library of graph algorithms.
*
* @copyright (c) 2017 David Mesquita-Morris
*
* Licensed under the MIT and GPL v3 licences
*/

// pull in the tree algorithms
export { Tree } from "./tree";
24 changes: 12 additions & 12 deletions test/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ describe("test/tree.js", function () {
});

it("Common ancestor", function () {
// assert.equal(root, tree.lowestCommonAncestor(root, root));
// assert.equal(root, tree.lowestCommonAncestor(root, left));
// assert.equal(root, tree.lowestCommonAncestor(root, right));
// assert.equal(root, tree.lowestCommonAncestor(root, rightLeft));
// assert.equal(root, tree.lowestCommonAncestor(root, rightRight));
// assert.equal(undefined, tree.lowestCommonAncestor(root, other));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(root), graph.Tree.ancestors(root)));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(root), graph.Tree.ancestors(left)));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(root), graph.Tree.ancestors(right)));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(root), graph.Tree.ancestors(rightLeft)));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(root), graph.Tree.ancestors(rightRight)));
assert.equal(-1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(root), graph.Tree.ancestors(other)));

assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(left), graph.Tree.ancestors(root)));
assert.equal(1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(left), graph.Tree.ancestors(left)));
Expand All @@ -57,12 +57,12 @@ describe("test/tree.js", function () {
assert.equal(1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightLeft), graph.Tree.ancestors(rightRight)));
assert.equal(-1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightLeft), graph.Tree.ancestors(other)));

// assert.equal(root, tree.lowestCommonAncestor(rightRight, root));
// assert.equal(root, tree.lowestCommonAncestor(rightRight, left));
// assert.equal(right, tree.lowestCommonAncestor(rightRight, right));
// assert.equal(right, tree.lowestCommonAncestor(rightRight, rightLeft));
// assert.equal(rightRight, tree.lowestCommonAncestor(rightRight, rightRight));
// assert.equal(undefined, tree.lowestCommonAncestor(rightRight, other));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightRight), graph.Tree.ancestors(root)));
assert.equal(0, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightRight), graph.Tree.ancestors(left)));
assert.equal(1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightRight), graph.Tree.ancestors(right)));
assert.equal(1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightRight), graph.Tree.ancestors(rightLeft)));
assert.equal(2, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightRight), graph.Tree.ancestors(rightRight)));
assert.equal(-1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(rightRight), graph.Tree.ancestors(other)));

assert.equal(-1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(other), graph.Tree.ancestors(root)));
assert.equal(-1, graph.Tree.lowestCommonAncestorIndex(graph.Tree.ancestors(other), graph.Tree.ancestors(left)));
Expand Down

0 comments on commit 1ffd620

Please sign in to comment.