From 486f460132434db1eaff92dcadb265011f394bf1 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 15 Jul 2008 16:09:40 +0200 Subject: pedigree rename to parentlinks: renamed files, to start with Signed-off-by: intrigeri --- t/parentlinks.t | 83 ++++++++++++++++++++++++++++++++ t/parentlinks/templates/parentlinks.tmpl | 4 ++ t/pedigree.t | 83 -------------------------------- t/pedigree/templates/pedigree.tmpl | 4 -- 4 files changed, 87 insertions(+), 87 deletions(-) create mode 100755 t/parentlinks.t create mode 100644 t/parentlinks/templates/parentlinks.tmpl delete mode 100755 t/pedigree.t delete mode 100644 t/pedigree/templates/pedigree.tmpl (limited to 't') diff --git a/t/parentlinks.t b/t/parentlinks.t new file mode 100755 index 000000000..74871cfa8 --- /dev/null +++ b/t/parentlinks.t @@ -0,0 +1,83 @@ +#!/usr/bin/perl +# -*- cperl-indent-level: 8; -*- +# Testcases for the Ikiwiki pedigree plugin. + +use warnings; +use strict; +use Test::More 'no_plan'; + +my %expected; + +BEGIN { use_ok("IkiWiki"); } + +# Init +%config=IkiWiki::defaultconfig(); +$config{srcdir}=$config{destdir}="/dev/null"; +$config{underlaydir}="underlays/basewiki"; +$config{templatedir}="t/pedigree/templates"; +IkiWiki::loadplugins(); +IkiWiki::checkconfig(); +ok(IkiWiki::loadplugin("pedigree"), "pedigree plugin loaded"); + +# Test data +$expected{'pedigree'} = + { + "" => [], + "ikiwiki" => [], + "ikiwiki/pagespec" => + [ {depth => 0, height => 2, }, + {depth => 1, height => 1, }, + ], + "ikiwiki/pagespec/attachment" => + [ {depth => 0, height => 3, depth_0 => 1, height_3 => 1}, + {depth => 1, height => 2, }, + {depth => 2, height => 1, }, + ], + }; + +# Test function +sub test_loop($$) { + my $loop=shift; + my $expected=shift; + my $template; + my %params; + + ok($template=template('pedigree.tmpl'), "template created"); + ok($params{template}=$template, "params populated"); + + while ((my $page, my $exp) = each %{$expected}) { + my @path=(split("/", $page)); + my $pagedepth=@path; + my $msgprefix="$page $loop"; + + # manually run the plugin hook + $params{page}=$page; + $template->clear_params(); + IkiWiki::Plugin::pedigree::pagetemplate(%params); + my $res=$template->param($loop); + + is(scalar(@$res), $pagedepth, "$msgprefix: path length"); + # logic & arithmetic validation tests + for (my $i=0; $i<$pagedepth; $i++) { + my $r=$res->[$i]; + is($r->{height}, $pagedepth - $r->{depth}, + "$msgprefix\[$i\]: height = pagedepth - depth"); + ok($r->{depth} ge 0, "$msgprefix\[$i\]: depth>=0"); + ok($r->{height} ge 0, "$msgprefix\[$i\]: height>=0"); + } + # comparison tests, iff the test-suite has been written + if (scalar(@$exp) eq $pagedepth) { + for (my $i=0; $i<$pagedepth; $i++) { + my $e=$exp->[$i]; + my $r=$res->[$i]; + map { is($r->{$_}, $e->{$_}, "$msgprefix\[$i\]: $_"); } keys %$e; + } + } + # else { + # diag("Testsuite is incomplete for ($page,$loop); cannot run comparison tests."); + # } + } +} + +# Main +test_loop('pedigree', $expected{'pedigree'}); diff --git a/t/parentlinks/templates/parentlinks.tmpl b/t/parentlinks/templates/parentlinks.tmpl new file mode 100644 index 000000000..5fa25733a --- /dev/null +++ b/t/parentlinks/templates/parentlinks.tmpl @@ -0,0 +1,4 @@ + + + + diff --git a/t/pedigree.t b/t/pedigree.t deleted file mode 100755 index 74871cfa8..000000000 --- a/t/pedigree.t +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/perl -# -*- cperl-indent-level: 8; -*- -# Testcases for the Ikiwiki pedigree plugin. - -use warnings; -use strict; -use Test::More 'no_plan'; - -my %expected; - -BEGIN { use_ok("IkiWiki"); } - -# Init -%config=IkiWiki::defaultconfig(); -$config{srcdir}=$config{destdir}="/dev/null"; -$config{underlaydir}="underlays/basewiki"; -$config{templatedir}="t/pedigree/templates"; -IkiWiki::loadplugins(); -IkiWiki::checkconfig(); -ok(IkiWiki::loadplugin("pedigree"), "pedigree plugin loaded"); - -# Test data -$expected{'pedigree'} = - { - "" => [], - "ikiwiki" => [], - "ikiwiki/pagespec" => - [ {depth => 0, height => 2, }, - {depth => 1, height => 1, }, - ], - "ikiwiki/pagespec/attachment" => - [ {depth => 0, height => 3, depth_0 => 1, height_3 => 1}, - {depth => 1, height => 2, }, - {depth => 2, height => 1, }, - ], - }; - -# Test function -sub test_loop($$) { - my $loop=shift; - my $expected=shift; - my $template; - my %params; - - ok($template=template('pedigree.tmpl'), "template created"); - ok($params{template}=$template, "params populated"); - - while ((my $page, my $exp) = each %{$expected}) { - my @path=(split("/", $page)); - my $pagedepth=@path; - my $msgprefix="$page $loop"; - - # manually run the plugin hook - $params{page}=$page; - $template->clear_params(); - IkiWiki::Plugin::pedigree::pagetemplate(%params); - my $res=$template->param($loop); - - is(scalar(@$res), $pagedepth, "$msgprefix: path length"); - # logic & arithmetic validation tests - for (my $i=0; $i<$pagedepth; $i++) { - my $r=$res->[$i]; - is($r->{height}, $pagedepth - $r->{depth}, - "$msgprefix\[$i\]: height = pagedepth - depth"); - ok($r->{depth} ge 0, "$msgprefix\[$i\]: depth>=0"); - ok($r->{height} ge 0, "$msgprefix\[$i\]: height>=0"); - } - # comparison tests, iff the test-suite has been written - if (scalar(@$exp) eq $pagedepth) { - for (my $i=0; $i<$pagedepth; $i++) { - my $e=$exp->[$i]; - my $r=$res->[$i]; - map { is($r->{$_}, $e->{$_}, "$msgprefix\[$i\]: $_"); } keys %$e; - } - } - # else { - # diag("Testsuite is incomplete for ($page,$loop); cannot run comparison tests."); - # } - } -} - -# Main -test_loop('pedigree', $expected{'pedigree'}); diff --git a/t/pedigree/templates/pedigree.tmpl b/t/pedigree/templates/pedigree.tmpl deleted file mode 100644 index 5fa25733a..000000000 --- a/t/pedigree/templates/pedigree.tmpl +++ /dev/null @@ -1,4 +0,0 @@ - - - - -- cgit v1.2.3