4 use Test::More tests => 9;
9 my @existing_pages=@{shift()};
11 %IkiWiki::pagecase=();
13 foreach my $page (@existing_pages) {
14 $IkiWiki::pagecase{lc $page}=$page;
15 $IkiWiki::links{$page}=[];
18 return IkiWiki::bestlink($page, $link);
21 BEGIN { use_ok("IkiWiki"); }
23 is(test("bar", "foo", ["bar"]), "", "broken link");
24 is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
25 is(test("bar", "FoO", ["bar", "foo"]), "foo", "simple link with different input case");
26 is(test("bar", "foo", ["bar", "fOo"]), "fOo", "simple link with different page case");
27 is(test("bar", "FoO", ["bar", "fOo"]), "fOo", "simple link with different page and input case");
28 is(test("bar", "Foo", ["bar", "fOo", "foo", "fOO", "Foo", "fOo"]), "Foo", "in case of ambiguity, like case wins");
29 is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
30 is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");