/*  test.js http://github.com/bgrins/javascript-astar
    MIT License
    
    Start of a test page for the astar search.  Still needs to be implemented...
*/

function runTest(grid, start, end) {
    var graph = new Graph(grid);
    var start = graph.nodes[start[0]][start[1]];
    var end = graph.nodes[end[0]][end[1]];
    var sTime = new Date();
    var result = astar.search(graph.nodes, start, end);
    var eTime = new Date();
    var text = "<pre>" + graph.toString() + "\n"+ result.length +" Steps (" + (eTime - sTime) + "ms)</pre>";
    return {
        result: result,
        time: (eTime - sTime),
        text: text
    };
}

$(function() {
    $("#runall").click(function() {

        var result1 = runTest([
            [1,1,1,1],
            [0,1,1,0],
            [0,0,1,1]
        ], [0,0], [2,3]);

        $("#test-output").append(result1.text);
        return false;
    });
});


@@ -67,13 +67,9 @@
 nse%0A
-    
 %0A
+
     
@@ -629,16 +629,350 @@
   %7D;%0A%7D%0A%0A
+// https://gist.github.com/bgrins/581352%0Afunction runBasic() %7B%0A    var graph = new Graph(%5B%0A        %5B1,1,1,1%5D,%0A        %5B0,1,1,0%5D,%0A        %5B0,0,1,1%5D%0A    %5D);%0A    var start = graph.nodes%5B0%5D%5B0%5D;%0A    var end = graph.nodes%5B1%5D%5B2%5D;%0A    var result = astar.search(graph.nodes, start, end);%0A%0A    return %22%3Cpre%3E%22 + result.join(%22, %22) + %22%3C/pre%3E%22;%0A%7D%0A%0A
 $(functi
@@ -1138,24 +1138,24 @@
 %5D, %5B2,3%5D);%0A%0A
-
         $(%22#
@@ -1190,16 +1190,62 @@
 .text);%0A
+        $(%22#test-output%22).append(runBasic());%0A
         

add basic test from gist