summaryrefslogtreecommitdiff
path: root/t/bestlink.t
blob: ed748b0f28fb6b3b2d5051946ed06b0aa42eda39 (plain)
  1. #!/usr/bin/perl
  2. use warnings;
  3. use strict;
  4. use Test::More tests => 5;
  5. sub test ($$$) {
  6. my $page=shift;
  7. my $link=shift;
  8. my @existing_pages=@{shift()};
  9. %IkiWiki::links=();
  10. foreach my $page (@existing_pages) {
  11. $IkiWiki::links{$page}=[];
  12. }
  13. return IkiWiki::bestlink($page, $link);
  14. }
  15. BEGIN { use_ok("IkiWiki"); }
  16. is(test("bar", "foo", ["bar"]), "", "broken link");
  17. is(test("bar", "foo", ["bar", "foo"]), "foo", "simple link");
  18. is(test("bar", "foo", ["bar", "foo", "bar/foo"]), "bar/foo", "simple subpage link");
  19. is(test("bar", "foo/subpage", ["bar", "foo", "bar/subpage", "foo/subpage"]), "foo/subpage", "cross subpage link");