4 use Test::More tests => 67;
6 BEGIN { use_ok("IkiWiki"); }
8 # Note that new objects have to be constructed freshly for each test, since
9 # object states are mutated as they are combined.
10 sub S { IkiWiki::SuccessReason->new("match") }
11 sub F { IkiWiki::FailReason->new("no match") }
12 sub E { IkiWiki::ErrorReason->new("error in matching") }
15 ok(F() eq "no match");
16 ok(E() eq "error in matching");
29 ok(!(!S() | F() | E()));
34 ok(!(S() & F() & E()));
35 ok(S() & (F() | F() | S()));
37 # influences are always merged, no matter the operation performed,
38 # as long as the two items are always both present
39 foreach my $op ('$s | $f', '$s & $f', '$s & $f & E()', '$s | E() | $f',
40 '! $s | ! $f', '!(!(!$s)) | $f') {
42 $s->influences(foo => 1, bar => 1);
43 is($s->influences->{foo}, 1);
44 is($s->influences->{bar}, 1);
46 $f->influences(bar => 2, baz => 1);
47 is($f->influences->{bar}, 2);
48 is($f->influences->{baz}, 1);
51 is($c->influences->{foo}, 1, "foo ($op)");
52 is($c->influences->{bar}, (1 | 2), "bar ($op)");
53 is($c->influences->{baz}, 1, "baz ($op)");