summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-08 16:49:53 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-08 17:53:20 -0400
commit5e236f5d25b68f5fb4a421b24470419c6042cb1c (patch)
treea35860cda1da576f263c0b4b5a0039e0f7cde2a3 /t
parentc57908b9d073500608d656adaf2bd3048c8cef67 (diff)
add use_pagespec and deptype functions
Diffstat (limited to 't')
-rwxr-xr-xt/use_pagespec.t30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/use_pagespec.t b/t/use_pagespec.t
new file mode 100755
index 000000000..7b904075e
--- /dev/null
+++ b/t/use_pagespec.t
@@ -0,0 +1,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");