2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 112; |
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; |
32 |
$abs_path =~ s#/[^/]*$#/#; |
$abs_path =~ s#/[^/]*$#/#; |
33 |
diag "abs_path: $abs_path" if ($debug); |
diag "abs_path: $abs_path" if ($debug); |
34 |
|
|
|
#throws_ok { new WebPAC::Normalize::XML( lookup_regex => 'foo' ) } qr/pair/, "lookup_regex without lookup"; |
|
|
|
|
35 |
my $rec1 = { |
my $rec1 = { |
36 |
'200' => [{ |
'200' => [{ |
37 |
'a' => '200a', |
'a' => '200a', |
107 |
}; |
}; |
108 |
|
|
109 |
|
|
110 |
my $lookup1 = { |
my $lookup_hash1 = { |
111 |
'00900' => [ |
'db1' => { |
112 |
'lookup 1', |
'input1' => { |
113 |
'lookup 2', |
'key1' => { 1 => 1 }, |
114 |
], |
'key2' => { 2 => 1 }, |
115 |
|
}, |
116 |
|
'input2' => { |
117 |
|
'key3' => { 3 => 1 }, |
118 |
|
'key4' => { 4 => 1 }, |
119 |
|
}, |
120 |
|
}, |
121 |
|
'db2' => { |
122 |
|
'input3' => { |
123 |
|
'key5' => { 5 => 1 }, |
124 |
|
'key6' => { 6 => 1 }, |
125 |
|
}, |
126 |
|
} |
127 |
}; |
}; |
128 |
|
|
129 |
my $lookup2 = { |
my $lookup_hash2 = { |
130 |
'00900' => 'lookup', |
'db3' => { |
131 |
|
'input4' => { |
132 |
|
'key7' => { 7 => 1 }, |
133 |
|
'key8' => { 8 => 1 }, |
134 |
|
}, |
135 |
|
} |
136 |
}; |
}; |
137 |
|
|
|
|
|
138 |
sub test { |
sub test { |
139 |
print dump( @_ ), ("-" x 78), "\n"; |
print dump( @_ ), ("-" x 78), "\n"; |
140 |
ok( defined(@_) ); |
ok( defined(@_) ); |
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 |
206 |
|
my @el; |
207 |
|
for my $i ( 0 .. 10 ) { |
208 |
|
cmp_ok( count( @el ), '==', $i, "count($i)"); |
209 |
|
push @el, "element $i"; |
210 |
|
} |
211 |
|
|
212 |
|
# lookups |
213 |
|
|
214 |
|
throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()'; |
215 |
|
|
216 |
|
ok(_set_load_row(sub { |
217 |
|
my ($database,$input,$mfn) = @_; |
218 |
|
diag "load_row( $database, $input, $mfn )" if ($debug); |
219 |
|
cmp_ok( $#_, '==', 2, 'have 3 arguments'); |
220 |
|
ok($database, '_load_row database'); |
221 |
|
ok($input, '_load_row input'); |
222 |
|
ok($mfn, '_load_row mfn'); |
223 |
|
return { |
224 |
|
'900' => [{ x => '900x-' . $mfn , y => '900y-' . $mfn }], |
225 |
|
} |
226 |
|
|
227 |
|
}), '_set_load_row'); |
228 |
|
|
229 |
|
my @v = qw/foo bar baz aaa bbb ccc ddd/; |
230 |
|
|
231 |
|
my @accumulated; |
232 |
|
|
233 |
|
for my $i ( 0 .. $#v ) { |
234 |
|
|
235 |
|
my $mfn = 1000 + $i; |
236 |
|
|
237 |
|
ok(WebPAC::Normalize::_set_config({ '_mfn' => $mfn }), "_set_config _mfn=$mfn"); |
238 |
|
|
239 |
|
my $size = $#v + 1; |
240 |
|
|
241 |
|
cmp_ok( |
242 |
|
save_into_lookup('db','input','key', sub { @v }), |
243 |
|
'==', $size, "save_into_lookup $size values" |
244 |
|
); |
245 |
|
|
246 |
|
ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup'); |
247 |
|
diag "_get_lookup = ", dump($l) if ($debug); |
248 |
|
|
249 |
|
my @lookup; |
250 |
|
|
251 |
|
ok(@lookup = lookup( |
252 |
|
sub { |
253 |
|
diag "in show" if ($debug); |
254 |
|
rec('900','x'); |
255 |
|
}, |
256 |
|
'db','input','key', |
257 |
|
sub { |
258 |
|
return @v; |
259 |
|
} |
260 |
|
), |
261 |
|
"lookup db/input/key"); |
262 |
|
|
263 |
|
push @accumulated, '900x-' . $mfn; |
264 |
|
|
265 |
|
is_deeply(\@lookup, \@accumulated, "lookup db/input/key"); |
266 |
|
|
267 |
|
shift @v; |
268 |
|
|
269 |
|
} |
270 |
|
|
271 |
|
ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup'); |
272 |
|
diag "_get_lookup = ", dump($l) if ($debug); |
273 |
|
|
274 |
|
is_deeply( $l, { |
275 |
|
db => { |
276 |
|
input => { |
277 |
|
key => { |
278 |
|
foo => { 1000 => 1 }, |
279 |
|
bar => { 1000 => 1, 1001 => 1 }, |
280 |
|
baz => { 1000 => 1, 1001 => 1, 1002 => 1 }, |
281 |
|
aaa => { 1000 => 1, 1001 => 1, 1002 => 1, 1003 => 1 }, |
282 |
|
bbb => { 1000 => 1, 1001 => 1, 1002 => 1, 1003 => 1, 1004 => 1 }, |
283 |
|
ccc => { 1000 => 1, 1001 => 1, 1002 => 1, 1003 => 1, 1004 => 1, 1005 => 1 }, |
284 |
|
ddd => { 1000 => 1, 1001 => 1, 1002 => 1, 1003 => 1, 1004 => 1, 1005 => 1, 1006 => 1 }, |
285 |
|
}, |
286 |
|
}, |
287 |
|
}, |
288 |
|
}, 'lookup data'); |
289 |
|
|
290 |
|
####### |
291 |
|
|
292 |
|
diag "lookup_hash1 = ", dump($lookup_hash1) if ($debug); |
293 |
|
ok(_set_lookup( $lookup_hash1 ), '_set_lookup $lookup_hash1'); |
294 |
|
|
295 |
|
throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()'; |
296 |
|
|
297 |
|
ok(_set_load_row(sub { |
298 |
|
my ($database,$input,$mfn) = @_; |
299 |
|
diag "load_row( $database, $input, $mfn )"; |
300 |
|
cmp_ok( $#_, '==', 2, 'have 3 arguments'); |
301 |
|
ok($database, 'database'); |
302 |
|
ok($input, 'input'); |
303 |
|
ok($mfn, 'mfn'); |
304 |
|
|
305 |
|
}), '_set_load_row'); |
306 |
|
|
307 |
|
|
308 |
|
# cmp_ok(lookup( |
309 |
|
# sub { |
310 |
|
# 'found' |
311 |
|
# }, |
312 |
|
# 'db1','input1','key1', |
313 |
|
# sub { |
314 |
|
# rec('200','a') |
315 |
|
# } |
316 |
|
# ), 'eq', 'found', 'lookup db1/input1/key1'); |
317 |
|
|
318 |
|
|
|
_set_lookup( $lookup1 ); |
|
319 |
|
|
320 |
cmp_ok( |
# cmp_ok( |
321 |
join_with(" i ", |
# lookup( |
322 |
lookup( |
# ), |
323 |
regex( 's/^/00/', |
# 'eq', 'lookup 1 i lookup 2', 'join lookup regex rec2'); |
|
rec2('902','z') |
|
|
) |
|
|
) |
|
|
), |
|
|
'eq', 'lookup 1 i lookup 2', 'join lookup regex rec2'); |
|
324 |
|
|
325 |
# check join_with operations |
# check join_with operations |
326 |
|
|
364 |
|
|
365 |
# test lookups |
# test lookups |
366 |
|
|
367 |
_set_lookup( $lookup2 ); |
_set_lookup( $lookup_hash2 ); |
368 |
|
|
369 |
|
throws_ok { lookup() } qr/need/, 'empty lookup'; |
370 |
|
|
371 |
is_deeply( \[ lookup( prefix( '00', rec('902') ) ) ], \[ 'lookup' ], 'lookup prefix' ); |
#is_deeply( \[ lookup( prefix( '00', rec('902') ) ) ], \[ 'lookup' ], 'lookup prefix' ); |
372 |
|
|
373 |
ok(! lookup('non-existent'), 'lookup non-existant' ); |
#ok(! lookup('non-existent'), 'lookup non-existant' ); |
374 |
|
|
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') |
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"; |
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 |
|
|
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 |
|
|
494 |
# |
# |
495 |
# MARC |
# MARC |
496 |
# |
# |
497 |
|
#_debug( 4 ); |
498 |
|
|
499 |
test_s(qq{ marc_indicators('900',1,2) }); |
test_s(qq{ marc_indicators('900',1,2) }); |
500 |
test_s(qq{ marc('900','a', rec('200') ) }); |
test_s(qq{ marc('900','a', rec('200') ) }); |
501 |
my @marc; |
my $marc; |
502 |
ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields"); |
ok($marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields"); |
503 |
diag dump( \@marc ) if ($debug); |
diag dump( $marc ) if ($debug); |
504 |
|
|
505 |
is_deeply( \@marc, [ |
is_deeply( $marc, [ |
506 |
[ '900', 1, 2, 'a', '200a' ], |
[ '900', 1, 2, 'a', '200a' ], |
507 |
[ '900', 1, 2, 'a', '200-solo' ] |
[ '900', 1, 2, 'a', '200-solo' ] |
508 |
], 'correct marc with indicators'); |
], 'correct marc with indicators'); |
510 |
test_s(qq{ marc_indicators('900',' ',9) }); |
test_s(qq{ marc_indicators('900',' ',9) }); |
511 |
test_s(qq{ marc_repeatable_subfield('900','a', rec('200') ) }); |
test_s(qq{ marc_repeatable_subfield('900','a', rec('200') ) }); |
512 |
|
|
513 |
ok(@marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields"); |
ok($marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields"); |
514 |
diag dump( \@marc ) if ($debug); |
diag dump( $marc ) if ($debug); |
515 |
|
|
516 |
is_deeply( \@marc, [ |
is_deeply( $marc, [ |
517 |
[ '900', 1, 2, 'a', '200a', 'a', '200-solo' ], |
[ '900', 1, 2, 'a', '200a', 'a', '200-solo' ], |
518 |
[ '900', ' ', 9, 'a', '200a', 'a', '200-solo' ] |
[ '900', ' ', 9, 'a', '200a', 'a', '200-solo' ] |
519 |
], 'correct marc with repetable subfield'); |
], 'correct marc with repetable subfield'); |
535 |
test_s($r) if ($r); |
test_s($r) if ($r); |
536 |
} |
} |
537 |
|
|
538 |
ok(my @marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields"); |
ok(my $marc = WebPAC::Normalize::_get_marc_fields(), "_get_marc_fields"); |
539 |
diag dump( \@marc ) if ($debug); |
diag dump( $marc ) if ($debug); |
540 |
diag "expects:\n", dump($struct) if ($debug > 1); |
diag "expects:\n", dump($struct) if ($debug > 1); |
541 |
is_deeply( \@marc, $struct, $msg ); |
is_deeply( $marc, $struct, $msg ); |
542 |
} |
} |
543 |
|
|
544 |
test_rec_rules( |
test_rec_rules( |
613 |
], |
], |
614 |
); |
); |
615 |
|
|
616 |
|
test_rec_rules( |
617 |
|
'marc_compose with + subfields', |
618 |
|
{ '200' => [{ a => 'foo ; bar', b => 42, c => 'baz' }] }, |
619 |
|
qq{ |
620 |
|
marc_compose('900', |
621 |
|
'a', rec(200,'a'), |
622 |
|
'+', prefix(" * ", rec(200,'c')), |
623 |
|
'b', rec(200,'b'), |
624 |
|
'+', prefix(" : ", rec(200,'c')), |
625 |
|
); |
626 |
|
}, |
627 |
|
[ |
628 |
|
[ '900', ' ', ' ', 'a', 'foo ; bar * baz', 'b', '42 : baz' ] |
629 |
|
], |
630 |
|
); |
631 |
|
|
632 |
# |
# |
633 |
# test rules |
# test rules |
634 |
# |
# |
696 |
diag "leader: ", dump(marc_leader()) if ($debug); |
diag "leader: ", dump(marc_leader()) if ($debug); |
697 |
is_deeply(marc_leader(), { '06' => 42, 11 => 5 }, "marc_leader full"); |
is_deeply(marc_leader(), { '06' => 42, 11 => 5 }, "marc_leader full"); |
698 |
|
|
|
_debug(2); |
|
699 |
test_rule( |
test_rule( |
700 |
'rec1(000)', |
'rec1(000)', |
701 |
{ '000' => [ 42 ]}, |
{ '000' => [ 42 ]}, |
704 |
); |
); |
705 |
|
|
706 |
test_rec_rules( |
test_rec_rules( |
707 |
'marc_compose+split_rec_on', |
'marc(001,rec(000))', |
708 |
{ '000' => [ 42 ]}, |
{ '000' => [ 42 ]}, |
709 |
qq{ |
qq{ |
710 |
marc('001', rec('000') ); |
marc('001', rec('000') ); |
711 |
}, |
}, |
712 |
[ |
[ |
713 |
[ '001', ' ', ' ', 42, ] |
[ '001', 42, ] |
714 |
], |
], |
715 |
); |
); |
716 |
|
|
717 |
|
test_rec_rules( |
718 |
|
'marc_remove subfield', |
719 |
|
{ '200' => [{ a => 42, b => 'bar', c => 'baz' }] }, |
720 |
|
qq{ |
721 |
|
marc('900', 'a', rec('200','a') ); |
722 |
|
marc('900', 'b', rec('200','b') ); |
723 |
|
marc_remove('900','b'); |
724 |
|
marc('900', 'b', rec('200','c') ); |
725 |
|
marc_remove('900','a'); |
726 |
|
}, |
727 |
|
[ |
728 |
|
[ '900', ' ', ' ', 'b', 'baz' ], |
729 |
|
], |
730 |
|
); |
731 |
|
|
732 |
|
test_rec_rules( |
733 |
|
'marc_remove field', |
734 |
|
{ '200' => [{ a => 42, b => 'bar', c => 'baz' }] }, |
735 |
|
qq{ |
736 |
|
marc('900', 'a', rec('200','a') ); |
737 |
|
marc('900', 'b', rec('200','b') ); |
738 |
|
marc('901', 'b', rec('200','b') ); |
739 |
|
marc('901', 'c', rec('200','c') ); |
740 |
|
marc_remove('900'); |
741 |
|
}, |
742 |
|
[ |
743 |
|
[ '901', ' ', ' ', 'b', 'bar', 'c', 'baz' ], |
744 |
|
], |
745 |
|
); |
746 |
|
|
747 |
|
test_s(qq{ marc_remove('*'); }); |
748 |
|
ok(! WebPAC::Normalize::_get_marc_fields(), 'marc_remove(*)'); |
749 |
|
|
750 |
|
test_rec_rules( |
751 |
|
'marc_duplicate', |
752 |
|
{ '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] }, |
753 |
|
qq{ |
754 |
|
marc_leader('06',42); |
755 |
|
marc_leader('11',0); |
756 |
|
marc('900', 'a', rec('200','a') ); |
757 |
|
marc('900', 'b', rec('200','b') ); |
758 |
|
marc_duplicate; |
759 |
|
marc_leader('11',1); |
760 |
|
marc_remove('900','b'); |
761 |
|
marc('900', 'b', rec('200','c') ); |
762 |
|
marc_duplicate; |
763 |
|
marc_leader('11',2); |
764 |
|
marc_remove('900','b'); |
765 |
|
marc('900', 'b', rec('200','d') ); |
766 |
|
marc_duplicate; |
767 |
|
marc_leader('11',3); |
768 |
|
marc_remove('900','b'); |
769 |
|
marc('900', 'b', rec('200','e') ); |
770 |
|
}, |
771 |
|
[ |
772 |
|
# this will return FIRST record |
773 |
|
[ '900', ' ', ' ', 'a', 42, 'b', 'bar' ], |
774 |
|
], |
775 |
|
); |
776 |
|
|
777 |
|
cmp_ok( marc_count(), '==', 3, 'marc_count' ); |
778 |
|
|
779 |
|
my $i = 0; |
780 |
|
foreach my $v ( qw/bar baz bing bong/ ) { |
781 |
|
|
782 |
|
ok($marc = WebPAC::Normalize::_get_marc_fields( offset => $i ), |
783 |
|
"_get_marc_fields( offset => $i )" |
784 |
|
); |
785 |
|
diag "marc $i = ", dump( $marc ) if ($debug); |
786 |
|
is_deeply( $marc, |
787 |
|
[ [ '900', ' ', ' ', 'a', 42, 'b', $v ] ], |
788 |
|
"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++; |
792 |
|
} |
793 |
|
|
794 |
|
test_rec_rules( |
795 |
|
'marc_original_order', |
796 |
|
{ |
797 |
|
'200' => [ { |
798 |
|
a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ], |
799 |
|
subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ], |
800 |
|
}, { |
801 |
|
a => [ 'a3', 'a4', 'a5' ], b => 'b3', c => 'c3', |
802 |
|
subfields => [ qw/a 0 a 1 b 0 c 0 a 2/ ], |
803 |
|
} ], |
804 |
|
}, |
805 |
|
qq{ |
806 |
|
marc_original_order(900,200); |
807 |
|
}, |
808 |
|
[ |
809 |
|
[ '900', ' ', ' ', 'a', 'a1', 'b', 'b1', 'a', 'a2', 'b', 'b2', 'c', 'c1', 'c', 'c2', ], |
810 |
|
[ '900', ' ', ' ', 'a', 'a3', 'a', 'a4', 'b', 'b3', 'c', 'c3', 'a', 'a5', ], |
811 |
|
], |
812 |
|
); |
813 |
|
|
814 |
|
test_rule( |
815 |
|
'rec1 skips subfields', |
816 |
|
{ |
817 |
|
'200' => [ { |
818 |
|
a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ], |
819 |
|
subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ], |
820 |
|
}, { |
821 |
|
a => [ 'a3', 'a4', 'a5' ], b => 'b3', c => 'c3', |
822 |
|
subfields => [ qw/a 0 a 1 b 0 c 0 a 2/ ], |
823 |
|
} ], |
824 |
|
}, |
825 |
|
qq{ |
826 |
|
rec1(200); |
827 |
|
}, |
828 |
|
['a1', 'b1', 'a2', 'b2', 'c1', 'c2', 'a3', 'a4', 'b3', 'c3', 'a5' ], |
829 |
|
); |
830 |
|
|
831 |
|
is_deeply( |
832 |
|
[ _pack_subfields_hash({ |
833 |
|
a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ], |
834 |
|
subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ], |
835 |
|
}) ], |
836 |
|
['a1', 'b1', 'a2', 'b2', 'c1', 'c2'], |
837 |
|
'_pack_subfields_hash( $h )' |
838 |
|
); |
839 |
|
|
840 |
|
cmp_ok( |
841 |
|
_pack_subfields_hash({ |
842 |
|
a => [ 'a1', 'a2' ], b => [ 'b1', 'b2' ], c => [ 'c1', 'c2' ], |
843 |
|
subfields => [ qw/a 0 b 0 a 1 b 1 c 0 c 1/ ], |
844 |
|
}, 1), |
845 |
|
'eq', |
846 |
|
'^aa1^bb1^aa2^bb2^cc1^cc2', |
847 |
|
'_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 |
|
|