]> sipb.mit.edu Git - ikiwiki.git/blobdiff - t/pagespec_match_list.t
Allow hooks to add sorting functions to pagespec_match_list
[ikiwiki.git] / t / pagespec_match_list.t
index dd5dcc5b087bcff878b9c35e1904fdee856edb7c..b34ee769f6c139425da64ce0e836131254c14458 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 88;
+use Test::More tests => 89;
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -9,6 +9,8 @@ BEGIN { use_ok("IkiWiki"); }
 $config{srcdir}=$config{destdir}="/dev/null";
 IkiWiki::checkconfig();
 
+hook(type => "sort", id => "path", call => sub { $_[0] cmp $_[1] });
+
 %pagesources=(
        foo => "foo.mdwn",
        foo2 => "foo2.mdwn",
@@ -34,6 +36,8 @@ is_deeply([pagespec_match_list("foo", "post/*", sort => "title", num => 50)],
 is_deeply([pagespec_match_list("foo", "post/*", sort => "title",
                          filter => sub { $_[0] =~ /3/}) ],
        ["post/1", "post/2"]);
+is_deeply([pagespec_match_list("foo", "*", sort => "path", num => 2)],
+       ["bar", "foo"]);
 my $r=eval { pagespec_match_list("foo", "beep") };
 ok(eval { pagespec_match_list("foo", "beep") } == 0);
 ok(! $@, "does not fail with error when unable to match anything");