/[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 547 by dpavlin, Thu Jun 29 23:19:26 2006 UTC revision 550 by dpavlin, Fri Jun 30 18:48:33 2006 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 75;  use Test::More tests => 81;
6  use Test::Exception;  use Test::Exception;
7  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
8  use blib;  use blib;
9  use File::Slurp;  use File::Slurp;
10    
11  use Data::Dumper;  use Data::Dump qw/dump/;
12  my $debug = shift @ARGV;  my $debug = shift @ARGV;
13    
14  BEGIN {  BEGIN {
# Line 109  my $lookup2 = { Line 109  my $lookup2 = {
109    
110    
111  sub test {  sub test {
112          print Dumper( @_ ), ("-" x 78), "\n";          print dump( @_ ), ("-" x 78), "\n";
113          ok( defined(@_) );          ok( defined(@_) );
114  }  }
115    
# Line 256  sub test_s { Line 256  sub test_s {
256          });          });
257    
258          ok(my $ds = _get_ds(), "get_ds");          ok(my $ds = _get_ds(), "get_ds");
259          diag "ds = ", Dumper($ds) if ($debug);          diag "ds = ", dump($ds) if ($debug);
260    
261    
262          sub test_check_ds {          sub test_check_ds {
# Line 264  sub test_s { Line 264  sub test_s {
264                  my $t = shift;                  my $t = shift;
265    
266                  ok($ds = _get_ds(), 'get_ds');                  ok($ds = _get_ds(), 'get_ds');
267                  diag Dumper( $ds ) if ($debug);                  diag dump( $ds ) if ($debug);
268    
269                  ok( $ds && $ds->{something}, 'get_ds->something exists' );                  ok( $ds && $ds->{something}, 'get_ds->something exists' );
270                  ok( $ds && $ds->{something}->{$t}, 'get_ds->something->'.$t.' exists') if ($t);                  ok( $ds && $ds->{something}->{$t}, 'get_ds->something->'.$t.' exists') if ($t);
# Line 296  sub test_s { Line 296  sub test_s {
296          test_s( $n );          test_s( $n );
297    
298          ok($ds = _get_ds(), "get_ds");          ok($ds = _get_ds(), "get_ds");
299          diag "ds = ", Dumper($ds) if ($debug);          diag "ds = ", dump($ds) if ($debug);
300    
301          my $rec = {          my $rec = {
302                  '200' => [{                  '200' => [{
# Line 346  sub test_s { Line 346  sub test_s {
346          test_s(qq{ marc('900','a', rec('200') ) });          test_s(qq{ marc('900','a', rec('200') ) });
347          my @marc;          my @marc;
348          ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");          ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");
349            diag dump( \@marc ) if ($debug);
350    
351          is_deeply( \@marc, [          is_deeply( \@marc, [
352                  [ '900', 1, 2, 'a', '200a' ],                  [ '900', 1, 2, 'a', '200a' ],
# Line 356  sub test_s { Line 357  sub test_s {
357          test_s(qq{ marc_repeatable_subfield('900','a', rec('200') ) });          test_s(qq{ marc_repeatable_subfield('900','a', rec('200') ) });
358    
359          ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");          ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");
360            diag dump( \@marc ) if ($debug);
361    
362          is_deeply( \@marc, [          is_deeply( \@marc, [
363                  [ '900', 1, 2, 'a', '200a', 'a', '200-solo' ],                  [ '900', 1, 2, 'a', '200a', 'a', '200-solo' ],
364                  [ '900', ' ', 9, 'a', '200a', 'a', '200-solo' ]                  [ '900', ' ', 9, 'a', '200a', 'a', '200-solo' ]
365          ], 'correct marc with repetable subfield');          ], 'correct marc with repetable subfield');
366    
367            _clean_ds();
368            _set_rec({
369                    '200' => [{
370                            'a' => '200a-1',
371                            'b' => '200b-1',
372                            'c' => '200c-1',
373                    }, {
374                            'a' => '200a-2',
375                            'b' => '200b-2',
376                            'c' => '200c-2',
377                    }, {
378                            'a' => '200a-3',
379                            'c' => '200c-3',
380                    }]
381            });
382            test_s(qq{ marc_indicators('900',1 ,0) });
383            test_s(qq{ marc_repeatable_subfield('900','a', rec('200','a') ) });
384            test_s(qq{ marc('900','b', rec('200','b') ) });
385            test_s(qq{ marc('900','c', rec('200','c') ) });
386    
387            ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields");
388            diag dump( \@marc ) if ($debug);
389    
390            is_deeply( \@marc, [
391                    [ '900', 1, 0, 'a', '200a-1', 'a', '200a-2', 'a', '200a-3', 'b', '200b-1', 'c', '200c-1' ],
392                    [ '900', 1, 0, 'b', '200b-2', 'c', '200c-2' ],
393                    [ '900', 1, 0, 'c', '200c-3' ],
394            ], 'correct marc with repetable subfield');
395  }  }
396    

Legend:
Removed from v.547  
changed lines
  Added in v.550

  ViewVC Help
Powered by ViewVC 1.1.26