Skip to content

Commit

Permalink
Updated specs, as of upstream changes
Browse files Browse the repository at this point in the history
Fixes #5
  • Loading branch information
Yonaba committed Apr 9, 2013
1 parent c23db31 commit 71da346
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 48 deletions.
40 changes: 1 addition & 39 deletions specs/grid_specs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,7 @@ context('Module Grid', function()
end
end
end)

test('Handles clearance', function()
local map = {{0,0,0},{0,1,0},{0,0,0}}
local grid = Grid(map)
local bigAgentClearance = 2
local littleAgentClearance = 1
assert_false(grid:isWalkableAt(1,2,0,bigAgentClearance))
assert_true(grid:isWalkableAt(1,2,0,littleAgentClearance))
end)

end)

context('Grid:getMap()', function()
Expand Down Expand Up @@ -506,34 +498,4 @@ context('Module Grid', function()

end)

context('Grid:evalClearance()', function()

test('returns the amount of clearance for the given node', function()
local map = {{0,0,0,0},{1,0,0,0},{0,0,0,0}}
local grid = Grid(map)
local walkable = 0
local NodeA = grid:getNodeAt(1,1)
local NodeB = grid:getNodeAt(1,2)
local NodeC = grid:getNodeAt(2,2)
local NodeD = grid:getNodeAt(3,2)
assert_equal(grid:evalClearance(NodeA,walkable),1)
assert_equal(grid:evalClearance(NodeB,walkable),1)
assert_equal(grid:evalClearance(NodeC,walkable),2)
assert_equal(grid:evalClearance(NodeD,walkable),2)
end)
end)

context('Grid:removeClearance()', function()

test('clears the cached clearance value', function()
local map = {{0,0,0,0},{1,0,0,0},{0,0,0,0}}
local grid = Grid(map)
local walkable = 0
local NodeA = grid:getNodeAt(1,1)
assert_equal(grid:evalClearance(NodeA,walkable),1)
grid:removeClearance(NodeA,walkable)
assert_nil(NodeA:getClearance(walkable))
end)
end)

end)
18 changes: 9 additions & 9 deletions specs/pathfinder_specs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ context('Module Pathfinder', function()

end)

context('Pathfinder:evalGridClearance()', function()
context('Pathfinder:annotateGrid()', function()

test('Calculates clearance for the entire grid', function()
local map = {
Expand All @@ -329,33 +329,33 @@ context('Module Pathfinder', function()
{6,5,5,4,4,3,3,3,2,1},
{6,5,4,4,3,3,2,2,2,1},
{6,5,4,3,3,2,2,1,1,1},
{6,5,4,3,2,2,1,1,1,1},
{5,5,4,3,2,1,1,1,1,1},
{4,4,4,3,2,1,1,2,1,1},
{3,3,3,3,3,3,3,2,1,1},
{6,5,4,3,2,2,1,1,0,1},
{5,5,4,3,2,1,1,0,1,1},
{4,4,4,3,2,1,0,2,1,0},
{3,3,3,3,3,3,3,2,1,0},
{2,2,2,2,2,2,2,2,2,1},
{1,1,1,1,1,1,1,1,1,1}
}
local grid = Grid(map)
local walkable = function(v) return v~=2 end
local finder = PF(grid, 'ASTAR', walkable)
finder:evalGridClearance()
finder:annotateGrid()
for node in grid:iter() do
assert_equal(node:getClearance(walkable), clearances[node._y][node._x])
end
end)

end)

context('Pathfinder:removeClerance()', function()
context('Pathfinder:clearAnnotations()', function()

test('Clears cached clearance values for the entire grid', function()
local map = {{0,1,0},{0,0,0},{1,1,0}}
local grid = Grid(map)
local walkable = 0
local finder = PF(grid, 'ASTAR', walkable)
finder:evalGridClearance()
finder:removeClearance()
finder:annotateGrid()
finder:clearAnnotations()
for node in grid:iter() do
assert_nil(node:getClearance(walkable))
end
Expand Down

0 comments on commit 71da346

Please sign in to comment.