Anonymous avatar Anonymous committed 55273d3

Added more tests.

Comments (0)

Files changed (1)

modules/Shlomif-Sokoban-Solver/t/01-loading.t

 use strict;
 use warnings;
 
-use Test::More tests => 20;
+use Test::More tests => 25;
 
 use Shlomif::Sokoban::Solver::Board;
 
     $not_box->(4, 3, "4,3 is not a box");
     # TEST
     $not_box->(2, 4, "2,4 is not a box");
+
+    my $ok_reach = sub {
+        local $Test::Builder::Level = $Test::Builder::Level + 1;
+        my ($x, $y, $msg) = @_;
+
+        ok ($board->is_reachable($board->_init_state(), $x, $y), $msg);
+    };
+
+    # TEST
+    $ok_reach->(3, 4, "3,4 is reachable");
+    # TEST
+    $ok_reach->(2, 4, "2,4 is reachable");
+
+    my $not_reach = sub {
+        local $Test::Builder::Level = $Test::Builder::Level + 1;
+        my ($x, $y, $msg) = @_;
+
+        ok (!$board->is_reachable($board->_init_state(), $x, $y), $msg);
+    };
+
+    
+    # TEST
+    $not_reach->(1, 2, "1,2 is not reachable since it's outside the walls");
+    # TEST
+    $not_reach->(3, 3, "3,3 is not reachable since it's a box");
+    # TEST
+    $not_reach->(3, 0, "3,0 is not reachable since it's a wall");
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.