Skip to content

Commit

Permalink
added tests for all operators
Browse files Browse the repository at this point in the history
  • Loading branch information
polettix committed Apr 2, 2012
1 parent dd68620 commit 351b78b
Showing 1 changed file with 43 additions and 9 deletions.
52 changes: 43 additions & 9 deletions t/10-sets.t
Expand Up @@ -10,24 +10,26 @@ use lib qw< t >;
use ASTest;

for my $test (test_specifications()) { # defined below
my ($t1, $op, $t2, $result) = @{$test}{qw< t1 op t2 result >};
my ($t1, $ops, $t2, $result) = @{$test}{qw< t1 op t2 result >};
$t1 = locate_file($t1);
$t2 = locate_file($t2);
{
my $res = sets_run($t1, $op, $t2);
is($res->{output}, $result, "$t1 $op $t2 - as separate items");
}
{
my $res = sets_run("$t1 $op $t2");
is($res->{output}, $result, "$t1 $op $t2 - as single string");
for my $op (ref $ops ? @$ops : $ops) {
{
my $res = sets_run($t1, $op, $t2);
is($res->{output}, $result, "$t1 $op $t2 - as separate items");
}
{
my $res = sets_run("$t1 $op $t2");
is($res->{output}, $result, "$t1 $op $t2 - as single string");
}
}
}

sub test_specifications {
return (
{
t1 => 'lista1',
op => '-',
op => [qw< minus less \ - >],
t2 => 'lista2',
result => 'nono
quarto
Expand All @@ -36,5 +38,37 @@ sesto
',
},

{
t1 => 'lista1',
op => [qw< union u U v V | + >],
t2 => 'lista2',
result => 'ancora
decimo
nono
nullo
ottavo
primo
quarto
quinto
secondo
sesto
settimo
terzo
undicesimo
',
},

{
t1 => 'lista1',
op => [qw< intersect i I & ^ >],
t2 => 'lista2',
result => 'decimo
ottavo
primo
quinto
settimo
terzo
',
},
);
}

0 comments on commit 351b78b

Please sign in to comment.