summaryrefslogtreecommitdiff
path: root/t/pagespec_match.t
blob: 1863b9cbabf550752646de2cc079ee9138c2ae3f (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 31;
  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. ok(IkiWiki::pagespec_match("foo", "creation_year(2006)"), "year");
  26. ok(! IkiWiki::pagespec_match("foo", "creation_year(2005)"), "other year");
  27. ok(IkiWiki::pagespec_match("foo", "creation_month(8)"), "month");
  28. ok(! IkiWiki::pagespec_match("foo", "creation_month(9)"), "other month");
  29. ok(IkiWiki::pagespec_match("foo", "creation_day(2)"), "day");
  30. ok(! IkiWiki::pagespec_match("foo", "creation_day(3)"), "other day");
  31. # old style globlists
  32. ok(IkiWiki::pagespec_match("foo", "foo bar"), "simple list");
  33. ok(IkiWiki::pagespec_match("bar", "foo bar"), "simple list 2");
  34. ok(IkiWiki::pagespec_match("foo", "f?? !foz"));
  35. ok(! IkiWiki::pagespec_match("foo", "f?? !foo"));
  36. ok(! IkiWiki::pagespec_match("foo", "* !foo"));
  37. ok(! IkiWiki::pagespec_match("foo", "foo !foo"));
  38. ok(! IkiWiki::pagespec_match("foo.png", "* !*.*"));