Permalink
Browse files

Missed a spot renaming _nextId.

Add a test case confirming that two instances have different IDs, which might have caught this mistake.
  • Loading branch information...
sbj42 committed Mar 27, 2017
1 parent efd67d9 commit db0bedb8fe5b1ff63835f605e46f64b71958e002
Showing with 25 additions and 3 deletions.
  1. +1 −1 bin/easystar-0.3.1.js
  2. +1 −1 bin/easystar-0.3.1.min.js
  3. +1 −1 src/easystar.js
  4. +22 −0 test/easystartest.js
View
@@ -319,7 +319,7 @@ var EasyStar =
// Create the instance
var instance = new Instance();
instance.id = EasyStar._nextId++;
instance.id = nextInstanceId++;
instance.openList = new Heap(function (nodeA, nodeB) {
return nodeA.bestGuessDistance() - nodeB.bestGuessDistance();
});

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -274,7 +274,7 @@ EasyStar.js = function() {
// Create the instance
var instance = new Instance();
instance.id = EasyStar._nextId ++;
instance.id = nextInstanceId ++;
instance.openList = new Heap(function(nodeA, nodeB) {
return nodeA.bestGuessDistance() - nodeB.bestGuessDistance();
});
View
@@ -109,6 +109,28 @@ describe("EasyStar.js", function() {
setTimeout(done, 0);
});
it("Paths should have different IDs.", function() {
var easyStar = new EasyStar.js();
var map = [[1,1,0,1,1],
[1,1,0,1,1],
[1,1,0,1,1],
[1,1,1,1,1],
[1,1,1,1,1]];
easyStar.setGrid(map);
easyStar.setAcceptableTiles([1]);
var id1 = easyStar.findPath(1,2,3,2,onPathFound);
var id2 = easyStar.findPath(3,2,1,2,onPathFound);
expect(id1).toBeGreaterThan(0);
expect(id2).toBeGreaterThan(0);
expect(id1).not.toEqual(id2);
function onPathFound(path) {
}
});
it("It should be able to avoid a separate point successfully.", function(done) {
var easyStar = new EasyStar.js();
var map = [[1,1,0,1,1],

0 comments on commit db0bedb

Please sign in to comment.