Commits

shl...@b384bcd7-cfd4-0310-aca0-d78b80f7b91b  committed 397cf55

Add the script black-hole-solve with the tests.

  • Participants
  • Parent commits d7a897d

Comments (0)

Files changed (4)

File black-hole-solitaire/Games-Solitaire-BlackHole-Solver/Build.PL

         'Test::More' => 0,
     },
     add_to_cleanup      => [ 'Games-Solitaire-BlackHole-Solver-*' ],
+    script_files => ["scripts/black-hole-solve",],
     create_makefile_pl => 'traditional',
 );
 

File black-hole-solitaire/Games-Solitaire-BlackHole-Solver/MANIFEST

 inc/Test/Run/Builder.pm
 lib/Games/Solitaire/BlackHole/Solver/App.pm
 lib/Games/Solitaire/BlackHole/Solver.pm
+Makefile.PL
 MANIFEST
+META.yml
 README
+scripts/black-hole-solve
 t/00-load.t
 t/01-run.t
 t/data/26464608654870335080.bh.board.txt
 t/pod-coverage.t
 t/pod.t
-Makefile.PL
-META.yml

File black-hole-solitaire/Games-Solitaire-BlackHole-Solver/scripts/black-hole-solve

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Games::Solitaire::BlackHole::Solver::App;
+
+Games::Solitaire::BlackHole::Solver::App->new->run;
+
+=head1 NAME
+
+black-hole-solve - a solver for Black Hole Solitaire deals.
+
+=head1 SYNOPSIS
+
+B<black-hole-solve> [-o output-file.txt] /path/to/board
+
+make_pysol_board.py 500 black_hole | B<black-hole-solve> [-o output-file.txt] -
+
+=head1 DESCRIPTION
+
+This is a solver for Black Hole solitaire.
+
+=head1 SEE ALSO
+
+L<http://search.cpan.org/dist/Games-Solitaire-BlackHole-Solver/> - File-Dir-Dumper on the CPAN.
+
+L<http://pysolfc.sourceforge.net/doc/rules/blackhole.html>
+
+L<Games::Solitaire::BlackHole::Solver::App>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2010 Shlomi Fish
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/>
+
+=cut
+

File black-hole-solitaire/Games-Solitaire-BlackHole-Solver/t/01-run.t

 use strict;
 use warnings;
 
-use Test::More tests => 2;
+use Test::More tests => 4;
 
 use File::Spec;
 
     return File::Spec->catfile(File::Spec->curdir(), "t", "data", shift());
 }
 
-{
-    my $sol_fn = _filename("26464608654870335080.bh.sol.txt");
-    # TEST
-    ok (!system($^X, "-Mblib", "-MGames::Solitaire::BlackHole::Solver::App",
-            "-e", "Games::Solitaire::BlackHole::Solver::App->new()->run()",
-            "--",
-            "-o", $sol_fn,
-            _filename("26464608654870335080.bh.board.txt")
-        )
-    );
-
-    my $contents;
-    {
-        local $/;
-        open my $in, "<", $sol_fn,
-            or die "Could not open '$sol_fn' for reading.";
-        $contents = <$in>;
-        close($in);
-    }
-
-    # TEST
-    is (
-        $contents,
-        <<'EOF',
+my $solution1 = <<'EOF';
 Solved!
 2D
 3H
 5H
 4D
 EOF
+
+{
+    my $sol_fn = _filename("26464608654870335080.bh.sol.txt");
+    # TEST
+    ok (!system($^X, "-Mblib", "-MGames::Solitaire::BlackHole::Solver::App",
+            "-e", "Games::Solitaire::BlackHole::Solver::App->new()->run()",
+            "--",
+            "-o", $sol_fn,
+            _filename("26464608654870335080.bh.board.txt")
+        )
+    );
+
+    my $contents;
+    {
+        local $/;
+        open my $in, "<", $sol_fn,
+            or die "Could not open '$sol_fn' for reading.";
+        $contents = <$in>;
+        close($in);
+    }
+
+    # TEST
+    is (
+        $contents,
+        $solution1,
         "Testing for correct solution.",
     );
 
     unlink($sol_fn);
 }
+
+{
+    my $sol_fn = _filename("26464608654870335080.bh.sol.txt");
+    # TEST
+    ok (!system($^X, "-Mblib", File::Spec->catfile(File::Spec->curdir(), "scripts", "black-hole-solve"),
+            "-o", $sol_fn,
+            _filename("26464608654870335080.bh.board.txt")
+        )
+    );
+
+    my $contents;
+    {
+        local $/;
+        open my $in, "<", $sol_fn,
+            or die "Could not open '$sol_fn' for reading.";
+        $contents = <$in>;
+        close($in);
+    }
+
+    # TEST
+    is (
+        $contents,
+        $solution1,
+        "Testing for correct solution.",
+    );
+
+    unlink($sol_fn);
+}