~ubuntu-branches/ubuntu/natty/freecell-solver/natty

« back to all changes in this revision

Viewing changes to t/t/range-parallel-solver.t

  • Committer: Bazaar Package Importer
  • Author(s): RISKO Gergely
  • Date: 2009-03-15 23:42:21 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090315234221-sx95hxyfyfgi0pja
Tags: 2.16.0-1
* Imported Upstream version 2.16.0 (closes: #518440)
* cmake is the new buildsystem

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
use Test::More tests => 1;
 
7
use Carp;
 
8
use Data::Dumper;
 
9
use String::ShellQuote;
 
10
 
 
11
use Games::Solitaire::Verify::Solution;
 
12
 
 
13
sub verify_solution_test
 
14
{
 
15
    local $Test::Builder::Level = $Test::Builder::Level + 1;
 
16
 
 
17
    my $args = shift;
 
18
    my $msg = shift;
 
19
 
 
20
    my $deal = $args->{deal};
 
21
 
 
22
    if ($deal !~ m{\A[1-9][0-9]*\z})
 
23
    {
 
24
        confess "Invalid deal $deal";
 
25
    }
 
26
 
 
27
    my $theme = $args->{theme} || ["-l", "gi"];
 
28
 
 
29
    my $variant = $args->{variant}  || "freecell";
 
30
 
 
31
    my $fc_solve_exe = shell_quote($ENV{'FCS_PATH'} . "/fc-solve");
 
32
 
 
33
    open my $fc_solve_output, 
 
34
        "make_pysol_freecell_board.py $deal $variant | " .
 
35
        "$fc_solve_exe -g $variant " . shell_quote(@$theme) . " -p -t -sam |"
 
36
        or Carp::confess "Error! Could not open the fc-solve pipeline";
 
37
 
 
38
    # Initialise a column
 
39
    my $solution = Games::Solitaire::Verify::Solution->new(
 
40
        {
 
41
            input_fh => $fc_solve_output,
 
42
            variant => $variant,
 
43
        },
 
44
    );
 
45
 
 
46
    my $verdict = $solution->verify();
 
47
    my $test_verdict = ok (!$verdict, $msg);
 
48
 
 
49
    if (!$test_verdict)
 
50
    {
 
51
        diag("Verdict == " . Dumper($verdict));
 
52
    }
 
53
 
 
54
    close($fc_solve_output);
 
55
 
 
56
    return $test_verdict;
 
57
}
 
58
 
 
59
my $range_solver = $ENV{'FCS_PATH'} . "/freecell-solver-range-parallel-solve";
 
60
 
 
61
# TEST
 
62
ok (!system($range_solver, "1", "20", "10", "-l", "gi"), "Range solver was successful");
 
63