/[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 811 by dpavlin, Sun Apr 1 21:47:40 2007 UTC revision 923 by dpavlin, Wed Oct 31 00:26:43 2007 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 322;  use Test::More tests => 347;
6  use Test::Exception;  use Test::Exception;
7  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
8  use blib;  use blib;
# Line 191  sub test_s { Line 191  sub test_s {
191    
192          # simple list manipulatons          # simple list manipulatons
193          cmp_ok( join('', prefix('ab', 'cd') ), 'eq', 'abcd', 'prefix');          cmp_ok( join('', prefix('ab', 'cd') ), 'eq', 'abcd', 'prefix');
194            cmp_ok( join('-', prefix('', 'x', 'y') ), 'eq', 'x-y', 'prefix empty');
195            cmp_ok( join('-', prefix(0, 'x', 'y') ), 'eq', '0x-0y', 'prefix 0');
196    
197          cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix');          cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix');
198            cmp_ok( join('-', suffix('', 'x', 'y' ) ), 'eq', 'x-y', 'suffix empty');
199            cmp_ok( join('-', suffix(0, 'x', 'y' ) ), 'eq', 'x0-y0', 'suffix 0');
200    
201          cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround');          cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround');
202            cmp_ok( join('-', surround('', '', 'x','y','z') ), 'eq', 'x-y-z', 'surround empty');
203            cmp_ok( join('-', surround(0, 0, 'x','y','z') ), 'eq', '0x0-0y0-0z0', 'surround 0 0');
204    
205          # count          # count
206          my @el;          my @el;
# Line 367  sub test_s { Line 375  sub test_s {
375          _set_rec( $rec2 );          _set_rec( $rec2 );
376    
377          test_s(qq{          test_s(qq{
378                  tag('Title',                  search_display('Title',
379                          rec('200','a')                          rec('200','a')
380                  );                  );
381          });          });
382          test_s(qq{          test_s(qq{
383                  tag('Who',                  search_display('Who',
384                          join_with(" ",                          join_with(" ",
385                                  rec('702','a'),                                  rec('702','a'),
386                                  rec('702','b')                                  rec('702','b')
# Line 423  sub test_s { Line 431  sub test_s {
431          test_check_ds('display');          test_check_ds('display');
432    
433          _clean_ds();          _clean_ds();
434          test_s(qq{ tag('something', '42'); });          test_s(qq{ search_display('something', '42'); });
435          test_s(qq{ tag('empty', ''); });          test_s(qq{ search_display('empty', ''); });
436          test_check_ds('search');          test_check_ds('search');
437          test_check_ds('display');          test_check_ds('display');
438    
439          _clean_ds();          _clean_ds();
440            test_s(qq{ sorted('something', '42'); });
441            test_s(qq{ sorted('empty', ''); });
442            test_check_ds('sorted');
443    
444            _clean_ds();
445          my $n = read_file( "$abs_path/data/normalize.pl" );          my $n = read_file( "$abs_path/data/normalize.pl" );
446          $n .= "\n1;\n";          $n .= "\n1;\n";
447          #diag "normalize code:\n$n\n";          #diag "normalize code:\n$n\n";
# Line 452  sub test_s { Line 465  sub test_s {
465          is_deeply( $ds, {          is_deeply( $ds, {
466                  'mixed' => {                  'mixed' => {
467                          'search' => [ '200a', '200b' ],                          'search' => [ '200a', '200b' ],
                         'tag' => 'mixed'  
468                  }                  }
469          }, 'correct get_ds');          }, 'correct get_ds');
470    
# Line 476  sub test_s { Line 488  sub test_s {
488          is_deeply( $ds, {          is_deeply( $ds, {
489                  'mixed' => {                  'mixed' => {
490                          'search' => [ '200a', '200-solo' ],                          'search' => [ '200a', '200-solo' ],
                         'tag' => 'mixed'  
491                  }                  }
492          }, 'correct get_ds');          }, 'correct get_ds');
493    
# Line 740  sub test_s { Line 751  sub test_s {
751                  'marc_duplicate',                  'marc_duplicate',
752                  { '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] },                  { '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] },
753                  qq{                  qq{
754                            marc_leader('06',42);
755                            marc_leader('11',0);
756                          marc('900', 'a', rec('200','a') );                          marc('900', 'a', rec('200','a') );
757                          marc('900', 'b', rec('200','b') );                          marc('900', 'b', rec('200','b') );
758                          marc_duplicate;                          marc_duplicate;
759                            marc_leader('11',1);
760                          marc_remove('900','b');                          marc_remove('900','b');
761                          marc('900', 'b', rec('200','c') );                          marc('900', 'b', rec('200','c') );
762                          marc_duplicate;                          marc_duplicate;
763                            marc_leader('11',2);
764                          marc_remove('900','b');                          marc_remove('900','b');
765                          marc('900', 'b', rec('200','d') );                          marc('900', 'b', rec('200','d') );
766                          marc_duplicate;                          marc_duplicate;
767                            marc_leader('11',3);
768                          marc_remove('900','b');                          marc_remove('900','b');
769                          marc('900', 'b', rec('200','e') );                          marc('900', 'b', rec('200','e') );
770                  },                  },
# Line 758  sub test_s { Line 774  sub test_s {
774                  ],                  ],
775          );          );
776    
777            cmp_ok( marc_count(), '==', 3, 'marc_count' );
778    
779          my $i = 0;          my $i = 0;
780          foreach my $v ( qw/bar baz bing bong/ ) {          foreach my $v ( qw/bar baz bing bong/ ) {
781    
# Line 769  sub test_s { Line 787  sub test_s {
787                          [ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ],                          [ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ],
788                          "MARC copy $i has $v",                          "MARC copy $i has $v",
789                  );                  );
790                    is_deeply(WebPAC::Normalize::_get_marc_leader(), { '06' => 42, 11 => $i }, "_get_marc_leader copy $i");
791                  $i++;                  $i++;
792          }          }
793    
# Line 827  sub test_s { Line 846  sub test_s {
846                  '^aa1^bb1^aa2^bb2^cc1^cc2',                  '^aa1^bb1^aa2^bb2^cc1^cc2',
847                  '_pack_subfields_hash( $h, 1 )'                  '_pack_subfields_hash( $h, 1 )'
848          );          );
849    
850            _clean_ds();
851            test_s(qq{
852                    marc_fixed('008', 0, 'abcdef');
853                    marc_fixed('000', 5, '5');
854                    marc_fixed('000', 10, 'A');
855                    marc_fixed('000', 0, '0');
856            });
857            ok( my $m = WebPAC::Normalize::_get_marc_fields(), '_get_marc_fields');
858            diag dump( $m );
859            is_deeply( WebPAC::Normalize::_get_marc_fields(),
860                    [
861                            ["008", "abcdef"],
862                            #        0....5....10
863                            ["000", "0    5    A"]
864                    ]
865            );
866  }  }
867    

Legend:
Removed from v.811  
changed lines
  Added in v.923

  ViewVC Help
Powered by ViewVC 1.1.26