/[webpac2]/trunk/t/3-normalize.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.t

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

revision 578 by dpavlin, Mon Jul 3 21:08:07 2006 UTC revision 579 by dpavlin, Tue Jul 4 11:08:43 2006 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 140;  use Test::More tests => 147;
6  use Test::Exception;  use Test::Exception;
7  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
8  use blib;  use blib;
# Line 364  sub test_s { Line 364  sub test_s {
364    
365          test_s(qq{ marc_indicators('900',1,2) });          test_s(qq{ marc_indicators('900',1,2) });
366          test_s(qq{ marc('900','a', rec('200') ) });          test_s(qq{ marc('900','a', rec('200') ) });
367          my @marc;          my $marc;
368          ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");          ok($marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");
369          diag dump( \@marc ) if ($debug);          diag dump( $marc ) if ($debug);
370    
371          is_deeply( \@marc, [          is_deeply( $marc, [
372                  [ '900', 1, 2, 'a', '200a' ],                  [ '900', 1, 2, 'a', '200a' ],
373                  [ '900', 1, 2, 'a', '200-solo' ]                  [ '900', 1, 2, 'a', '200-solo' ]
374          ], 'correct marc with indicators');          ], 'correct marc with indicators');
# Line 376  sub test_s { Line 376  sub test_s {
376          test_s(qq{ marc_indicators('900',' ',9) });          test_s(qq{ marc_indicators('900',' ',9) });
377          test_s(qq{ marc_repeatable_subfield('900','a', rec('200') ) });          test_s(qq{ marc_repeatable_subfield('900','a', rec('200') ) });
378    
379          ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");          ok($marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");
380          diag dump( \@marc ) if ($debug);          diag dump( $marc ) if ($debug);
381    
382          is_deeply( \@marc, [          is_deeply( $marc, [
383                  [ '900', 1, 2, 'a', '200a', 'a', '200-solo' ],                  [ '900', 1, 2, 'a', '200a', 'a', '200-solo' ],
384                  [ '900', ' ', 9, 'a', '200a', 'a', '200-solo' ]                  [ '900', ' ', 9, 'a', '200a', 'a', '200-solo' ]
385          ], 'correct marc with repetable subfield');          ], 'correct marc with repetable subfield');
# Line 401  sub test_s { Line 401  sub test_s {
401                          test_s($r) if ($r);                          test_s($r) if ($r);
402                  }                  }
403    
404                  ok(my @marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");                  ok(my $marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");
405                  diag dump( \@marc ) if ($debug);                  diag dump( $marc ) if ($debug);
406                  diag "expects:\n", dump($struct) if ($debug > 1);                  diag "expects:\n", dump($struct) if ($debug > 1);
407                  is_deeply( \@marc, $struct, $msg );                  is_deeply( $marc, $struct, $msg );
408          }          }
409    
410          test_rec_rules(          test_rec_rules(
# Line 565  sub test_s { Line 565  sub test_s {
565          );          );
566    
567          test_rec_rules(          test_rec_rules(
568                  'marc_remove',                  'marc_remove subfield',
569                  { '200' => [{ a => 42, b => 'bar', c => 'baz' }] },                  { '200' => [{ a => 42, b => 'bar', c => 'baz' }] },
570                  qq{                  qq{
571                          marc('900', 'a', rec('200','a') );                          marc('900', 'a', rec('200','a') );
# Line 580  sub test_s { Line 580  sub test_s {
580          );          );
581    
582          test_rec_rules(          test_rec_rules(
583                    'marc_remove field',
584                    { '200' => [{ a => 42, b => 'bar', c => 'baz' }] },
585                    qq{
586                            marc('900', 'a', rec('200','a') );
587                            marc('900', 'b', rec('200','b') );
588                            marc('901', 'b', rec('200','b') );
589                            marc('901', 'c', rec('200','c') );
590                            marc_remove('900');
591                    },
592                    [
593                            [ '901', ' ', ' ', 'b', 'bar', 'c', 'baz' ],
594                    ],
595            );
596            test_rec_rules(
597                  'marc_duplicate',                  'marc_duplicate',
598                  { '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] },                  { '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] },
599                  qq{                  qq{
# Line 604  sub test_s { Line 618  sub test_s {
618          my $i = 0;          my $i = 0;
619          foreach my $v ( qw/bar baz bing bong/ ) {          foreach my $v ( qw/bar baz bing bong/ ) {
620    
621                  ok(@marc = WebPAC::Normalize::_get_marc_fields( offset => $i ),                  ok($marc = WebPAC::Normalize::_get_marc_fields( offset => $i ),
622                          "_get_marc_fields( offset => $i )"                          "_get_marc_fields( offset => $i )"
623                  );                  );
624                  diag "marc $i = ", dump( @marc ) if ($debug);                  diag "marc $i = ", dump( $marc ) if ($debug);
625                  is_deeply( \@marc,                  is_deeply( $marc,
626                          [ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ],                          [ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ],
627                          "MARC copy $i has $v",                          "MARC copy $i has $v",
628                  );                  );

Legend:
Removed from v.578  
changed lines
  Added in v.579

  ViewVC Help
Powered by ViewVC 1.1.26