]> git.donarmstrong.com Git - deb_pkgs/libhtml-calendarmonth-perl.git/blobdiff - t/testload.pm
switch to 3.0 quilt format
[deb_pkgs/libhtml-calendarmonth-perl.git] / t / testload.pm
index 1c30d0fa30547e619c749acd5940eb51bc7b74fa..51c5fffbc6f8695fc23d2eb6900776a5476ccd93 100644 (file)
@@ -16,15 +16,18 @@ require Exporter;
 use vars qw(
   $Dat_Dir
   $Bulk_File
+  $Head_File
   $Odd_File
   $Woy_File
-  $I8N_File
   $Narrow_File
+  $I8N_File
+  $I8N_Legacy1_File
+  $I8N_Legacy2_File
 );
 
 @EXPORT = qw(
   $Dat_Dir
-  $Bulk_File $Odd_File $Woy_File $I8N_File $Narrow_File
+  $Bulk_File $Head_File $Odd_File $Woy_File $I8N_File $Narrow_File
   check_datetool
   check_bulk_with_datetool
   check_odd_with_datetool
@@ -52,13 +55,16 @@ BEGIN {
   $Dat_Dir = File::Spec->catpath($vol, $dir, '');
 }
 
-$Bulk_File   = File::Spec->catdir($Dat_Dir,   'bulk.dat');
-$Odd_File    = File::Spec->catdir($Dat_Dir,    'odd.dat');
-$Woy_File    = File::Spec->catdir($Dat_Dir,    'woy.dat');
-$I8N_File    = File::Spec->catdir($Dat_Dir,    'i8n.dat');
-$Narrow_File = File::Spec->catdir($Dat_Dir, 'narrow.dat');
+$Bulk_File       = File::Spec->catdir($Dat_Dir,    'bulk.dat');
+$Head_File       = File::Spec->catdir($Dat_Dir,    'head.dat');
+$Odd_File        = File::Spec->catdir($Dat_Dir,     'odd.dat');
+$Woy_File        = File::Spec->catdir($Dat_Dir,     'woy.dat');
+$Narrow_File     = File::Spec->catdir($Dat_Dir,  'narrow.dat');
+$I8N_File        = File::Spec->catdir($Dat_Dir,     'i8n.dat');
+$I8N_Legacy1_File = File::Spec->catdir($Dat_Dir, 'i8n_leg1.dat');
+$I8N_Legacy2_File = File::Spec->catdir($Dat_Dir, 'i8n_leg2.dat');
 
-my(@Bulk, @Odd, @Woy, @I8N, @Nar);
+my(@Bulk, @Head, @Odd, @Woy, @I8N, @Nar);
 
 sub _load_file {
   my $f   = shift;
@@ -67,22 +73,33 @@ sub _load_file {
   return unless open(F, '<', $f);
   while (my $h = <F>) {
     chomp $h;
-    my($d, $wb) = split(/\s+/, $h);
+    my($d, $wb, @other) = split(/\s+/, $h);
     my($y, $m) = split(/\//, $d);
     my $c = <F>;
     chomp $c;
-    push(@$cal, [$d, $y, $m, $wb, clean($c)]);
+    push(@$cal, [$d, $y, $m, $wb, \@other, clean($c)]);
   }
   $cal;
 }
 
-_load_file($Bulk_File, \@Bulk   );
-_load_file($Odd_File,   \@Odd   );
-_load_file($Woy_File,    \@Woy  );
-_load_file($I8N_File,     \@I8N );
+_load_file($Bulk_File, \@Bulk    );
+_load_file($Head_File,  \@Head   );
+_load_file($Odd_File,    \@Odd   );
+_load_file($Woy_File,     \@Woy  );
 _load_file($Narrow_File,   \@Nar);
 
+if (HTML::CalendarMonth::Locale->_locale_version >= 1.03) {
+  _load_file($I8N_File, \@I8N );
+}
+elsif (HTML::CalendarMonth::Locale->_locale_version >= 0.93) {
+  _load_file($I8N_Legacy2_File, \@I8N );
+}
+else {
+  _load_file($I8N_Legacy1_File, \@I8N );
+}
+
 sub bulk_count   { scalar @Bulk }
+sub head_count   { scalar @Head }
 sub odd_count    { scalar @Odd  }
 sub woy_count    { scalar @Woy  }
 sub i8n_count    { scalar @I8N  }
@@ -121,7 +138,7 @@ sub check_bulk_with_datetool {
   my $datetool = shift;
   my @days;
   foreach (@Bulk) {
-    my($d, $y, $m, $wb, $tc) = @$_;
+    my($d, $y, $m, $wb, $other, $tc) = @$_;
     my $c = HTML::CalendarMonth->new(
       year       => $y,
       month      => $m,
@@ -140,11 +157,37 @@ sub check_bulk_with_datetool {
   }
 }
 
+sub check_head_with_datetool {
+  my $datetool = shift;
+  my @days;
+  foreach (@Head) {
+    my($d, $y, $m, $wb, $other, $tc) = @$_;
+    my($hm, $hy, $hd, $hw) = @$other;
+    my $c = HTML::CalendarMonth->new(
+      year       => $y,
+      month      => $m,
+      week_begin => $wb,
+      head_m     => $hm,
+      head_y     => $hy,
+      head_dow   => $hd,
+      head_week  => $hw,
+      datetool   => $datetool,
+    );
+    my $method = $c->_caltool->_name;
+    $method = "auto-select ($method)" unless $datetool;
+    my $msg = sprintf(
+      "(%d/%02d hm:%d hy:%d hd:%d hw:%d) using %s",
+      $y, $m, $hm, $hy, $hd, $hw, $method
+    );
+    cmp_ok(clean($c->as_HTML), 'eq', $tc, $msg);
+  }
+}
+
 sub check_odd_with_datetool {
   my $datetool = shift;
   my @days;
   foreach (@Odd) {
-    my($d, $y, $m, $wb, $tc) = @$_;
+    my($d, $y, $m, $wb, $other, $tc) = @$_;
     SKIP: {
       my $c;
       eval {
@@ -157,7 +200,7 @@ sub check_odd_with_datetool {
       };
       if ($@ || !$c) {
         croak $@ unless $@ =~ /(no|in)\s*valid date tool/i;
-        skip("$datetool skip odd $y/$m", 1);
+        skip("$datetool odd $y/$m", 1);
       }
       @days = $c->dayheaders unless @days;
       my $day1 = $days[$wb - 1];
@@ -175,7 +218,7 @@ sub check_odd_with_datetool {
 sub check_woy_with_datetool {
   my $datetool = shift;
   foreach (@Woy) {
-    my($d, $y, $m, $wb, $tc) = @$_;
+    my($d, $y, $m, $wb, $other, $tc) = @$_;
     my $c = HTML::CalendarMonth->new(
       year       => $y,
       month      => $m,
@@ -189,7 +232,7 @@ sub check_woy_with_datetool {
 
 sub check_i8n {
   foreach (@I8N) {
-    my($d, $y, $m, $id, $tc) = @$_;
+    my($d, $y, $m, $id, $other, $tc) = @$_;
     my $c = HTML::CalendarMonth->new(
       year   => $y,
       month  => $m,
@@ -207,7 +250,7 @@ sub check_i8n {
 sub check_narrow {
   my @days;
   foreach (@Nar) {
-    my($d, $y, $m, $wb, $tc) = @$_;
+    my($d, $y, $m, $wb, $other, $tc) = @$_;
     my $c = HTML::CalendarMonth->new(
       year       => $y,
       month      => $m,