summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-13 14:58:22 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-13 14:58:22 -0400
commitc916dcd035ef35e545119c91953a135600ecf0c3 (patch)
tree8f9878e2b02cf81e9c6fe188653be26ff44702ab
parent2f5beb59bff17ace9e33743d646a95204a9be5bc (diff)
fix some broken influence blocking testing, add more tests
-rwxr-xr-xt/pagespec_match_result.t41
1 files changed, 33 insertions, 8 deletions
diff --git a/t/pagespec_match_result.t b/t/pagespec_match_result.t
index d9c31d6f0..13fcdcad0 100755
--- a/t/pagespec_match_result.t
+++ b/t/pagespec_match_result.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 71;
+use Test::More tests => 138;
BEGIN { use_ok("IkiWiki"); }
@@ -34,10 +34,27 @@ ok(!(S() & F()));
ok(!(S() & F() & E()));
ok(S() & (F() | F() | S()));
-# influences are always merged, no matter the operation performed,
-# as long as the two items are always both present
-foreach my $op ('$s | $f', '$s & $f', '$s & $f & E()', '$s | E() | $f',
- '! $s | ! $f', '!(!(!$s)) | $f') {
+# influence merging tests
+foreach my $test (
+ ['$s | $f' => 1], # OR merges
+ ['! $s | ! $f' => 1], # OR merges with negated terms too
+ ['!(!(!$s)) | $f' => 1],# OR merges with multiple negation too
+ ['$s | $f | E()' => 1], # OR merges, even though E() has no influences
+ ['$s | E() | $f' => 1], # ditto
+ ['E() | $s | $f' => 1], # ditto
+ ['!$s | !$f | E()' => 1],# negated terms also do not block merges
+ ['!$s | E() | $f' => 1],# ditto
+ ['E() | $s | !$f' => 1],# ditto
+ ['$s & $f' => 1], # AND merges if both items have influences
+ ['!$s & $f' => 1], # AND merges negated terms too
+ ['$s & !$f' => 1], # AND merges negated terms too
+ ['$s & $f & E()' => 0], # AND fails to merge since E() has no influences
+ ['$s & E() & $f' => 0], # ditto
+ ['E() & $s & $f' => 0], # ditto
+ ) {
+ my $op=$test->[0];
+ my $influence=$test->[1];
+
my $s=S(foo => 1, bar => 1);
is($s->influences->{foo}, 1);
is($s->influences->{bar}, 1);
@@ -46,9 +63,14 @@ foreach my $op ('$s | $f', '$s & $f', '$s & $f & E()', '$s | E() | $f',
is($f->influences->{baz}, 1);
my $c = eval $op;
ok(ref $c);
- is($c->influences->{foo}, 1, "foo ($op)");
- is($c->influences->{bar}, (1 | 2), "bar ($op)");
- is($c->influences->{baz}, 1, "baz ($op)");
+ if ($influence) {
+ is($c->influences->{foo}, 1, "foo ($op)");
+ is($c->influences->{bar}, (1 | 2), "bar ($op)");
+ is($c->influences->{baz}, 1, "baz ($op)");
+ }
+ else {
+ ok(! %{$c->influences}, "no influence for ($op)");
+ }
}
my $s=S(foo => 0, bar => 1);
@@ -57,3 +79,6 @@ ok(! $s->influences->{foo}, "removed 0 influence");
ok(! $s->influences->{bar}, "removed 1 influence");
ok($s->influences->{baz}, "set influence");
ok($s->influences_static);
+$s=S(foo => 0, bar => 1);
+$s->influences(baz => 1, "" => 1);
+ok(! $s->influences_static);