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 { |
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 |
|
|
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 { |
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); |
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' => [{ |
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' ], |
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 |
|
|