tests for influence blocking

master
Joey Hess 2009-10-13 14:46:38 -04:00
parent a20bc7a3fc
commit 2f5beb59bf
1 changed files with 11 additions and 13 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl #!/usr/bin/perl
use warnings; use warnings;
use strict; use strict;
use Test::More tests => 61; use Test::More tests => 88;
BEGIN { use_ok("IkiWiki"); } BEGIN { use_ok("IkiWiki"); }
@ -86,23 +86,23 @@ foreach my $spec ("bar or (backlink(foo) and !*.png)", "backlink(foo)") {
%IkiWiki::depends=(); %IkiWiki::depends=();
} }
TODO: { # Hard fails due to a glob, etc, will block influences of other anded terms.
local $TODO = "optimisation not yet written"; foreach my $spec ("nosuchpage and link(bar)", "link(bar) and nosuchpage",
"link(bar) and */Discussion", "*/Discussion and link(bar)",
# a pagespec that hard fails due to a glob, etc, will not set influences "!foo2 and link(bar)", "link(bar) and !foo2") {
# for other terms that normally would.
foreach my $spec ("nosuchpage and link(bar)", "link(bar) and */Discussion") {
pagespec_match_list("foo2", $spec, deptype => deptype("presence")); pagespec_match_list("foo2", $spec, deptype => deptype("presence"));
ok($IkiWiki::depends{foo2}{$spec} & $IkiWiki::DEPEND_PRESENCE); ok($IkiWiki::depends{foo2}{$spec} & $IkiWiki::DEPEND_PRESENCE);
ok(! ($IkiWiki::depends{foo2}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_LINKS))); ok(! ($IkiWiki::depends{foo2}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_LINKS)));
ok(! exists $IkiWiki::depends_simple{foo2}{foo2}); ok(! exists $IkiWiki::depends_simple{foo2}{foo2}, "no influence from $spec");
%IkiWiki::depends_simple=(); %IkiWiki::depends_simple=();
%IkiWiki::depends=(); %IkiWiki::depends=();
} }
# a pagespec containing a hard failure that is ored with another term will # A hard fail will not block influences of other ored terms.
# get influences from the other term foreach my $spec ("nosuchpage or link(bar)", "link(bar) or nosuchpage",
foreach my $spec ("nosuchpage or link(bar)", "link(bar) or */Discussion") { "link(bar) or */Discussion", "*/Discussion or link(bar)",
"!foo2 or link(bar)", "link(bar) or !foo2",
"link(bar) or (!foo2 and !foo1)") {
pagespec_match_list("foo2", $spec, deptype => deptype("presence")); pagespec_match_list("foo2", $spec, deptype => deptype("presence"));
ok($IkiWiki::depends{foo2}{$spec} & $IkiWiki::DEPEND_PRESENCE); ok($IkiWiki::depends{foo2}{$spec} & $IkiWiki::DEPEND_PRESENCE);
ok(! ($IkiWiki::depends{foo2}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_LINKS))); ok(! ($IkiWiki::depends{foo2}{$spec} & ($IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_LINKS)));
@ -110,5 +110,3 @@ foreach my $spec ("nosuchpage or link(bar)", "link(bar) or */Discussion") {
%IkiWiki::depends_simple=(); %IkiWiki::depends_simple=();
%IkiWiki::depends=(); %IkiWiki::depends=();
} }
}