r1614@llin: dpavlin | 2007-11-12 12:56:56 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 12 Nov 2007 11:57:00 +0000 (11:57 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 12 Nov 2007 11:57:00 +0000 (11:57 +0000)
 demostrate problems with marc records returned

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1038 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Normalize.pm
lib/WebPAC/Normalize/MARC.pm
t/3-normalize-marc.t

index e7f7e9b..84b5fee 100644 (file)
@@ -263,7 +263,6 @@ sub _debug {
        warn "debug level $l",$/ if ($l > 0);
        $debug = $l;
        $WebPAC::Normalize::MARC::debug = $debug;
-warn "#### MARC::debug = ",dump($WebPAC::Normalize::MARC::debug);
 }
 
 =head1 Functions to create C<data_structure>
index c3d8dab..bddde1e 100644 (file)
@@ -17,7 +17,7 @@ use Carp qw/confess/;
 
 use WebPAC::Normalize;
 
-our $debug = 42;
+our $debug = 0;
 
 my ($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader);
 my ($marc_record_offset, $marc_fetch_offset) = (0, 0);
index 825c77f..2c8b0db 100755 (executable)
@@ -55,6 +55,7 @@ my $rec = {
 sub test_marc_template {
        my $rec = shift;
 
+       ok( _clean_ds(), '_clean_ds' );
        ok( _set_ds( $rec ), '_set_ds' );
 
        ok( marc_template(
@@ -89,7 +90,6 @@ sub test_marc_template {
 
 my $marc_out = [
        [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"],
        [440, " ", " ", "a", "a-2-1 ; ", "v", "v-2-1. ", "p", "i-2-1"],
        [440, " ", " ", "a", "a-3-1 ; ", "v", "v-3-1. ", "p", "i-3-1"],
        [440, " ", " ", "a", "a-4-1 ; ", "v", "v-4-1. ", "p", "i-4-1 ; ", "v", "w-4-1"],
@@ -97,24 +97,26 @@ my $marc_out = [
        [440, " ", " ", "a", "a-6-1. ", "p", "i-6-1 ; ", "v", "w-6-1"],
        [440, " ", " ", "a", "a-7-1"],
        [440, " ", " ", "a", "a-8-1 ;", "v", "v-8-1"],
+       [440, " ", " ", "v", "v-9-1"],
 ];
 
 is_deeply( test_marc_template($rec), $marc_out , 'is_deeply');
 
-__END__
-
 my $max_occ = $#{ $rec->{225} };
 
 foreach my $from ( 0 .. $max_occ - 1 ) {
-       foreach my $to ( 1 .. $max_occ ) {
+       foreach my $to ( $from + 1 .. $max_occ ) {
+               my @orig_rec = @{ $rec->{225} };
                my $new_rec = {
-                       225 => [ splice( @{ $rec->{225} }, $from, $to ) ],
+                       225 => [ splice( @orig_rec, $from, $to ) ],
                };
-               diag "new_rec = ",dump( $new_rec ) if $debug;
-       
-               my $expect_marc = [ splice( @{ $marc_out }, $from, $to ) ];
-               diag "expect_marc = ",dump( $expect_marc ) if $debug;
+               diag "$from-$to new_rec = ",dump( $new_rec ) if $debug;
+
+               my @expect = @$marc_out;
+               my $expect_marc = [ splice( @expect, $from, $to ) ];
+               diag "$from-$to expect_marc = ",dump( $expect_marc ) if $debug;
+
+               is_deeply( test_marc_template($new_rec), $expect_marc, "$from-$to is_deeply");
 
-               is_deeply( [ test_marc_template($rec) ], $expect_marc, 'is_deeply');
        }
 }