Commits

Anonymous committed 665f825

Add the regression test suite.

This is to be able to do the upcoming refactoring (on the way to implementing
the backtracking) with confidence.

Comments (0)

Files changed (3)

abc-path/perl-quick-and-dirty/Makefile

+all:
+
+test:
+	runprove -l t/*.t
+
+runtest:
+	runprove -l t/*.t

abc-path/perl-quick-and-dirty/t/refactoring-temp-system-test.t

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+use Test::Differences;
+
+sub _slurp
+{
+    my $filename = shift;
+
+    open my $in, "<", $filename
+        or die "Cannot open '$filename' for slurping - $!";
+
+    local $/;
+    my $contents = <$in>;
+
+    close($in);
+
+    return $contents;
+}
+
+{
+    my $got_results =
+        `perl abc-path-solver.pl layouts/brain-bashers.2010-12-22.abc-path`
+        ;
+
+    # TEST
+    ok ((!$?), "Process ended successfully.");
+
+    my $exp_results =
+        _slurp('./t/results/brain-bashers.2010-12-22.abc-path-sol');
+
+    # TEST
+    eq_or_diff(
+        $got_results,
+        $exp_results,
+        "Output is OK.",
+    );
+}
+
+=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.
+
+=cut
+

abc-path/perl-quick-and-dirty/t/results/brain-bashers.2010-12-22.abc-path-sol

+B cannot be at (3,1) due to lack of vicinity from A.
+B cannot be at (4,1) due to lack of vicinity from A.
+C cannot be at (1,3) due to lack of vicinity from B.
+C cannot be at (1,4) due to lack of vicinity from B.
+D cannot be at (3,0) due to lack of vicinity from C.
+D cannot be at (4,0) due to lack of vicinity from C.
+E cannot be at (0,2) due to lack of vicinity from D.
+E cannot be at (0,3) due to lack of vicinity from D.
+E cannot be at (0,4) due to lack of vicinity from D.
+D cannot be at (2,0) due to lack of vicinity from E.
+F cannot be at (0,3) due to lack of vicinity from E.
+F cannot be at (0,4) due to lack of vicinity from E.
+G cannot be at (2,2) due to lack of vicinity from F.
+G cannot be at (3,2) due to lack of vicinity from F.
+G cannot be at (4,2) due to lack of vicinity from F.
+For G only (0,2) is possible.
+F cannot be at (0,0) due to lack of vicinity from G.
+H cannot be at (2,3) due to lack of vicinity from G.
+H cannot be at (3,3) due to lack of vicinity from G.
+H cannot be at (4,3) due to lack of vicinity from G.
+I cannot be at (1,0) due to lack of vicinity from H.
+I cannot be at (1,1) due to lack of vicinity from H.
+J cannot be at (3,4) due to lack of vicinity from I.
+J cannot be at (4,4) due to lack of vicinity from I.
+K cannot be at (4,0) due to lack of vicinity from J.
+K cannot be at (3,1) due to lack of vicinity from J.
+K cannot be at (2,2) due to lack of vicinity from J.
+L cannot be at (3,4) due to lack of vicinity from K.
+L cannot be at (4,4) due to lack of vicinity from K.
+M cannot be at (2,0) due to lack of vicinity from L.
+M cannot be at (2,1) due to lack of vicinity from L.
+M cannot be at (2,2) due to lack of vicinity from L.
+L cannot be at (0,4) due to lack of vicinity from M.
+N cannot be at (0,0) due to lack of vicinity from M.
+N cannot be at (1,1) due to lack of vicinity from M.
+N cannot be at (4,4) due to lack of vicinity from M.
+P cannot be at (0,0) due to lack of vicinity from O.
+P cannot be at (4,4) due to lack of vicinity from O.
+Q cannot be at (3,0) due to lack of vicinity from P.
+P cannot be at (1,1) due to lack of vicinity from Q.
+S cannot be at (0,0) due to lack of vicinity from R.
+S cannot be at (4,0) due to lack of vicinity from R.
+R cannot be at (2,2) due to lack of vicinity from S.
+R cannot be at (2,3) due to lack of vicinity from S.
+R cannot be at (2,4) due to lack of vicinity from S.
+T cannot be at (2,2) due to lack of vicinity from S.
+T cannot be at (1,3) due to lack of vicinity from S.
+T cannot be at (0,4) due to lack of vicinity from S.
+S cannot be at (1,0) due to lack of vicinity from T.
+U cannot be at (0,1) due to lack of vicinity from T.
+U cannot be at (1,1) due to lack of vicinity from T.
+V cannot be at (4,3) due to lack of vicinity from U.
+V cannot be at (4,4) due to lack of vicinity from U.
+U cannot be at (2,1) due to lack of vicinity from V.
+W cannot be at (0,3) due to lack of vicinity from V.
+W cannot be at (1,3) due to lack of vicinity from V.
+W cannot be at (2,3) due to lack of vicinity from V.
+V cannot be at (4,0) due to lack of vicinity from W.
+V cannot be at (4,1) due to lack of vicinity from W.
+X cannot be at (4,0) due to lack of vicinity from W.
+X cannot be at (4,1) due to lack of vicinity from W.
+Y cannot be at (3,0) due to lack of vicinity from X.
+The only letter that can be at (3,0) is S. Invalidating it for all other cells.
+The only letter that can be at (4,0) is T. Invalidating it for all other cells.
+The only letter that can be at (4,1) is U. Invalidating it for all other cells.
+The only letter that can be at (0,3) is H. Invalidating it for all other cells.
+The only letter that can be at (2,3) is M. Invalidating it for all other cells.
+The only letter that can be at (4,4) is X. Invalidating it for all other cells.
+For F only (0,1) is possible.
+Q cannot be at (3,3) due to lack of vicinity from R.
+Q cannot be at (3,4) due to lack of vicinity from R.
+For V only (4,2) is possible.
+Y cannot be at (3,1) due to lack of vicinity from X.
+Y cannot be at (3,2) due to lack of vicinity from X.
+The only letter that can be at (2,0) is R. Invalidating it for all other cells.
+The only letter that can be at (2,1) is B. Invalidating it for all other cells.
+The only letter that can be at (3,1) is Q. Invalidating it for all other cells.
+The only letter that can be at (3,2) is O. Invalidating it for all other cells.
+The only letter that can be at (4,3) is W. Invalidating it for all other cells.
+The only letter that can be at (3,4) is Y. Invalidating it for all other cells.
+For E only (0,0) is possible.
+P cannot be at (3,3) due to lack of vicinity from Q.
+The only letter that can be at (1,1) is C. Invalidating it for all other cells.
+The only letter that can be at (3,3) is N. Invalidating it for all other cells.
+For D only (1,0) is possible.
+For P only (2,2) is possible.
+ | X = 0 | X = 1 | X = 2 | X = 3 | X = 4 | 
+ | E     | D     | R     | S     | T     | 
+ | F     | C     | B     | Q     | U     | 
+ | G     | A     | P     | O     | V     | 
+ | H     | I,K   | M     | N     | W     | 
+ | J,K   | I,J,L | J,L   | Y     | X     |