summaryrefslogtreecommitdiff
path: root/t/pagespec_match.t
blob: 20243dfa69855ab2c84539262a1f16940d320014 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 35;
  5. BEGIN { use_ok("IkiWiki"); }
  6. ok(IkiWiki::pagespec_match("foo", "*"));
  7. ok(IkiWiki::pagespec_match("page", "?ag?"));
  8. ok(! IkiWiki::pagespec_match("page", "?a?g?"));
  9. ok(IkiWiki::pagespec_match("foo.png", "*.*"));
  10. ok(! IkiWiki::pagespec_match("foo", "*.*"));
  11. ok(IkiWiki::pagespec_match("foo", "foo or bar"), "simple list");
  12. ok(IkiWiki::pagespec_match("bar", "foo or bar"), "simple list 2");
  13. ok(IkiWiki::pagespec_match("foo", "f?? and !foz"));
  14. ok(! IkiWiki::pagespec_match("foo", "f?? and !foo"));
  15. ok(! IkiWiki::pagespec_match("foo", "* and !foo"));
  16. ok(! IkiWiki::pagespec_match("foo", "foo and !foo"));
  17. ok(! IkiWiki::pagespec_match("foo.png", "* and !*.*"));
  18. ok(IkiWiki::pagespec_match("foo", "(bar or ((meep and foo) or (baz or foo) or beep))"));
  19. $IkiWiki::links{foo}=[qw{bar baz}];
  20. ok(IkiWiki::pagespec_match("foo", "link(bar)"));
  21. ok(! IkiWiki::pagespec_match("foo", "link(quux)"));
  22. ok(IkiWiki::pagespec_match("bar", "backlink(foo)"));
  23. ok(! IkiWiki::pagespec_match("quux", "backlink(foo)"));
  24. $IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006
  25. $IkiWiki::pagectime{bar}=1154532695; # after
  26. ok(IkiWiki::pagespec_match("foo", "created_before(bar)"));
  27. ok(! IkiWiki::pagespec_match("foo", "created_after(bar)"));
  28. ok(! IkiWiki::pagespec_match("bar", "created_before(foo)"));
  29. ok(IkiWiki::pagespec_match("bar", "created_after(foo)"));
  30. ok(IkiWiki::pagespec_match("foo", "creation_year(2006)"), "year");
  31. ok(! IkiWiki::pagespec_match("foo", "creation_year(2005)"), "other year");
  32. ok(IkiWiki::pagespec_match("foo", "creation_month(8)"), "month");
  33. ok(! IkiWiki::pagespec_match("foo", "creation_month(9)"), "other month");
  34. ok(IkiWiki::pagespec_match("foo", "creation_day(2)"), "day");
  35. ok(! IkiWiki::pagespec_match("foo", "creation_day(3)"), "other day");
  36. # old style globlists
  37. ok(IkiWiki::pagespec_match("foo", "foo bar"), "simple list");
  38. ok(IkiWiki::pagespec_match("bar", "foo bar"), "simple list 2");
  39. ok(IkiWiki::pagespec_match("foo", "f?? !foz"));
  40. ok(! IkiWiki::pagespec_match("foo", "f?? !foo"));
  41. ok(! IkiWiki::pagespec_match("foo", "* !foo"));
  42. ok(! IkiWiki::pagespec_match("foo", "foo !foo"));
  43. ok(! IkiWiki::pagespec_match("foo.png", "* !*.*"));