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