X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=t%2Ftestload.pm;h=e1f8efcc222e1384876ba8aa8564f6201734fad5;hb=9a2930defe8c992ecc154a1056314997f4b19fae;hp=902069dc854e6120204cdb38236f98f08abd140c;hpb=50065656489ae7e83457ab2c12b6d174186339d7;p=deb_pkgs%2Flibhtml-calendarmonth-perl.git diff --git a/t/testload.pm b/t/testload.pm index 902069d..e1f8efc 100644 --- a/t/testload.pm +++ b/t/testload.pm @@ -9,9 +9,10 @@ my $DEBUG = 0; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw( $Dat_Dir check_datetool +@EXPORT = qw( $Dat_Dir check_datetool case_count check_basic_with_datetool check_woy_with_datetool + dq_nums ); use File::Spec; @@ -19,21 +20,23 @@ use File::Spec; use HTML::CalendarMonth; use HTML::CalendarMonth::DateTool; -my $base_dir; +my($base_dir, $vol, $dir); BEGIN { my $pkg = __PACKAGE__; $pkg =~ s%::%/%g; $pkg .= '.pm'; $pkg = File::Spec->canonpath($INC{$pkg}); - $pkg =~ s/\/[^\/]+\.pm$//; - $base_dir = $pkg; + my $file; + ($vol, $dir, $file) = File::Spec->splitpath($pkg); + $base_dir = File::Spec->catpath($vol, $dir, ''); } $Dat_Dir = $base_dir; my($tcount, $rds, %dates, @tmethods, @twy_methods, @Cals); # Required test dates -open(D, "$Dat_Dir/test.dat") or die "Problem reading $Dat_Dir/test.dat: $!\n"; +my $dat_file = File::Spec->catpath($vol, $dir, 'test.dat'); +open(D, "<$dat_file") or die "Problem reading $dat_file: $!\n"; $rds = ; foreach (split(' ', $rds)) { ++$dates{$_}; @@ -66,6 +69,19 @@ while () { close(D); +############# + +# guard against HTML::Tree starting to quote numeric attrs as of +# v3.19_02 + +sub dq_nums { + my $str = shift; + $str =~ s/\"(\d+)\"/$1/g; + return $str; +} + +sub case_count { scalar @Cals } + sub check_datetool { my $datetool = shift; my $module = HTML::CalendarMonth::DateTool->toolmap($datetool); @@ -84,8 +100,11 @@ sub check_basic_with_datetool { week_begin => $cal->[3], datetool => $datetool, ); + # Because HTML::TreeBuilder has changed a few times, this can't be exactly equal + my $gen_html = $c->as_HTML; + $gen_html =~ s/\=\"(\d+)\"/=$1/g; my $day1 = $days[$cal->[3] - 1]; - cmp_ok($c->as_HTML, 'eq', $cal->[2], + cmp_ok(dq_nums($c->as_HTML), 'eq', $cal->[2], sprintf("(%d/%-02d %s 1st day) using %s", $cal->[0], $cal->[1], $day1, $method)); if ($DEBUG && $c->as_HTML ne $cal->[2]) { @@ -105,8 +124,9 @@ sub check_woy_with_datetool { head_week => 1, datetool => $datetool, ); - my $ct = $cal->as_HTML; + my $ct = dq_nums($cal->as_HTML); chomp $ct; + $ct =~ s/\=\"(\d+)\"/=$1/g; cmp_ok($ct, 'eq', $tc, "($year/$month week of year) using $datetool"); if ($DEBUG && $ct ne $tc) { debug_dump('Broken', $ct, 'Test Data', $tc);