2006-05-02 23:14:50 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2006-08-13 04:08:42 +02:00
|
|
|
use Test::More tests => 9;
|
2006-05-02 23:14:50 +02:00
|
|
|
|
|
|
|
sub test ($$$) {
|
|
|
|
my $page=shift;
|
|
|
|
my $link=shift;
|
|
|
|
my @existing_pages=@{shift()};
|
|
|
|
|
2006-08-13 04:03:43 +02:00
|
|
|
%IkiWiki::pagecase=();
|
2006-08-13 04:08:42 +02:00
|
|
|
%IkiWiki::links=();
|
2006-05-02 23:14:50 +02:00
|
|
|
foreach my $page (@existing_pages) {
|
2006-08-13 04:03:43 +02:00
|
|
|
$IkiWiki::pagecase{lc $page}=$page;
|
2006-08-13 04:08:42 +02:00
|
|
|
$IkiWiki::links{$page}=[];
|
2006-05-02 23:14:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return IkiWiki::bestlink($page, $link);
|
|
|
|
}
|
|
|
|
|
|
|
|
BEGIN { use_ok("IkiWiki"); }
|
|
|
|
|
|
|
|
is(test("bar", "foo", ["bar"]), "", "broken link");
|
|
|
|
is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
|
2006-08-13 04:03:43 +02:00
|
|
|
is(test("bar", "FoO", ["bar", "foo"]), "foo", "simple link with different input case");
|
|
|
|
is(test("bar", "foo", ["bar", "fOo"]), "fOo", "simple link with different page case");
|
|
|
|
is(test("bar", "FoO", ["bar", "fOo"]), "fOo", "simple link with different page and input case");
|
2006-08-13 04:08:42 +02:00
|
|
|
is(test("bar", "Foo", ["bar", "fOo", "foo", "fOO", "Foo", "fOo"]), "Foo", "in case of ambiguity, like case wins");
|
2006-05-02 23:14:50 +02:00
|
|
|
is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
|
|
|
|
is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");
|