/[webpac2]/trunk/t/3-normalize-marc.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/3-normalize-marc.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1037 by dpavlin, Mon Nov 12 11:17:19 2007 UTC revision 1038 by dpavlin, Mon Nov 12 11:57:00 2007 UTC
# Line 55  my $rec = { Line 55  my $rec = {
55  sub test_marc_template {  sub test_marc_template {
56          my $rec = shift;          my $rec = shift;
57    
58            ok( _clean_ds(), '_clean_ds' );
59          ok( _set_ds( $rec ), '_set_ds' );          ok( _set_ds( $rec ), '_set_ds' );
60    
61          ok( marc_template(          ok( marc_template(
# Line 89  sub test_marc_template { Line 90  sub test_marc_template {
90    
91  my $marc_out = [  my $marc_out = [
92          [440, " ", " ", "a", "a-1-1, ", "x", "x-1-1 ; ", "v", "v-1-1. ", "n", "h-1-1, ", "p", "i-1-1 ; ", "v", "w-1-1"],          [440, " ", " ", "a", "a-1-1, ", "x", "x-1-1 ; ", "v", "v-1-1. ", "n", "h-1-1, ", "p", "i-1-1 ; ", "v", "w-1-1"],
         [440, " ", " ", "v", "v-9-1"],  
93          [440, " ", " ", "a", "a-2-1 ; ", "v", "v-2-1. ", "p", "i-2-1"],          [440, " ", " ", "a", "a-2-1 ; ", "v", "v-2-1. ", "p", "i-2-1"],
94          [440, " ", " ", "a", "a-3-1 ; ", "v", "v-3-1. ", "p", "i-3-1"],          [440, " ", " ", "a", "a-3-1 ; ", "v", "v-3-1. ", "p", "i-3-1"],
95          [440, " ", " ", "a", "a-4-1 ; ", "v", "v-4-1. ", "p", "i-4-1 ; ", "v", "w-4-1"],          [440, " ", " ", "a", "a-4-1 ; ", "v", "v-4-1. ", "p", "i-4-1 ; ", "v", "w-4-1"],
# Line 97  my $marc_out = [ Line 97  my $marc_out = [
97          [440, " ", " ", "a", "a-6-1. ", "p", "i-6-1 ; ", "v", "w-6-1"],          [440, " ", " ", "a", "a-6-1. ", "p", "i-6-1 ; ", "v", "w-6-1"],
98          [440, " ", " ", "a", "a-7-1"],          [440, " ", " ", "a", "a-7-1"],
99          [440, " ", " ", "a", "a-8-1 ;", "v", "v-8-1"],          [440, " ", " ", "a", "a-8-1 ;", "v", "v-8-1"],
100            [440, " ", " ", "v", "v-9-1"],
101  ];  ];
102    
103  is_deeply( test_marc_template($rec), $marc_out , 'is_deeply');  is_deeply( test_marc_template($rec), $marc_out , 'is_deeply');
104    
 __END__  
   
105  my $max_occ = $#{ $rec->{225} };  my $max_occ = $#{ $rec->{225} };
106    
107  foreach my $from ( 0 .. $max_occ - 1 ) {  foreach my $from ( 0 .. $max_occ - 1 ) {
108          foreach my $to ( 1 .. $max_occ ) {          foreach my $to ( $from + 1 .. $max_occ ) {
109                    my @orig_rec = @{ $rec->{225} };
110                  my $new_rec = {                  my $new_rec = {
111                          225 => [ splice( @{ $rec->{225} }, $from, $to ) ],                          225 => [ splice( @orig_rec, $from, $to ) ],
112                  };                  };
113                  diag "new_rec = ",dump( $new_rec ) if $debug;                  diag "$from-$to new_rec = ",dump( $new_rec ) if $debug;
114            
115                  my $expect_marc = [ splice( @{ $marc_out }, $from, $to ) ];                  my @expect = @$marc_out;
116                  diag "expect_marc = ",dump( $expect_marc ) if $debug;                  my $expect_marc = [ splice( @expect, $from, $to ) ];
117                    diag "$from-$to expect_marc = ",dump( $expect_marc ) if $debug;
118    
119                    is_deeply( test_marc_template($new_rec), $expect_marc, "$from-$to is_deeply");
120    
                 is_deeply( [ test_marc_template($rec) ], $expect_marc, 'is_deeply');  
121          }          }
122  }  }

Legend:
Removed from v.1037  
changed lines
  Added in v.1038

  ViewVC Help
Powered by ViewVC 1.1.26