aboutsummaryrefslogtreecommitdiff
path: root/t/use_pagespec.t
blob: 7b904075ed477b58258f3318a19ab3273dfaf22f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
use warnings;
use strict;
use Test::More tests => 64;

BEGIN { use_ok("IkiWiki"); }

%pagesources=(
	foo => "foo.mdwn",
	bar => "bar.mdwn",
	"post/1" => "post/1.mdwn",
	"post/2" => "post/2.mdwn",
	"post/3" => "post/3.mdwn",
);

is_deeply([use_pagespec("foo", "bar")], ["bar"]);
is_deeply([sort(use_pagespec("foo", "post/*"))], ["post/1", "post/2", "post/3"]);
is_deeply([use_pagespec("foo", "post/*", sort => "title", reverse => 1)],
	["post/3", "post/2", "post/1"]);
is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 2)],
	["post/1", "post/2"]);
is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 50)],
	["post/1", "post/2", "post/3"]);
is_deeply([use_pagespec("foo", "post/*", sort => "title",
                         limit => sub { $_[0] !~ /3/}) ],
	["post/1", "post/2"]);
eval { use_pagespec("foo", "beep") };
ok($@, "fails with error when unable to match anything");
eval { use_pagespec("foo", "this is not a legal pagespec!") };
ok($@, "fails with error when pagespec bad");