summaryrefslogtreecommitdiff
path: root/t/use_pagespec.t
blob: 92d7977cfd94ee0e7c672b5a1d1ce784d2bff6c6 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 10;
  5. BEGIN { use_ok("IkiWiki"); }
  6. %pagesources=(
  7. foo => "foo.mdwn",
  8. bar => "bar.mdwn",
  9. "post/1" => "post/1.mdwn",
  10. "post/2" => "post/2.mdwn",
  11. "post/3" => "post/3.mdwn",
  12. );
  13. is_deeply([use_pagespec("foo", "bar")], ["bar"]);
  14. is_deeply([sort(use_pagespec("foo", "post/*"))], ["post/1", "post/2", "post/3"]);
  15. is_deeply([use_pagespec("foo", "post/*", sort => "title", reverse => 1)],
  16. ["post/3", "post/2", "post/1"]);
  17. is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 2)],
  18. ["post/1", "post/2"]);
  19. is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 50)],
  20. ["post/1", "post/2", "post/3"]);
  21. is_deeply([use_pagespec("foo", "post/*", sort => "title",
  22. limit => sub { $_[0] !~ /3/}) ],
  23. ["post/1", "post/2"]);
  24. my $r=eval { use_pagespec("foo", "beep") };
  25. ok(eval { use_pagespec("foo", "beep") } == 0);
  26. ok(! $@, "does not fail with error when unable to match anything");
  27. eval { use_pagespec("foo", "this is not a legal pagespec!") };
  28. ok($@, "fails with error when pagespec bad");