2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 309; |
use Test::More tests => 322; |
6 |
use Test::Exception; |
use Test::Exception; |
7 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
8 |
use blib; |
use blib; |
194 |
cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix'); |
cmp_ok( join('', suffix('xy', 'cd') ), 'eq', 'cdxy', 'suffix'); |
195 |
cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround'); |
cmp_ok( join('', surround('->', '<-', 'a','b','c') ), 'eq', '->a<-->b<-->c<-', 'surround'); |
196 |
|
|
197 |
|
# count |
198 |
|
my @el; |
199 |
|
for my $i ( 0 .. 10 ) { |
200 |
|
cmp_ok( count( @el ), '==', $i, "count($i)"); |
201 |
|
push @el, "element $i"; |
202 |
|
} |
203 |
|
|
204 |
# lookups |
# lookups |
205 |
|
|
206 |
throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()'; |
throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()'; |
207 |
|
|
208 |
ok(_set_load_row(sub { |
ok(_set_load_row(sub { |
209 |
my ($database,$input,$mfn) = @_; |
my ($database,$input,$mfn) = @_; |
210 |
diag "load_row( $database, $input, $mfn )"; |
diag "load_row( $database, $input, $mfn )" if ($debug); |
211 |
cmp_ok( $#_, '==', 2, 'have 3 arguments'); |
cmp_ok( $#_, '==', 2, 'have 3 arguments'); |
212 |
ok($database, '_load_row database'); |
ok($database, '_load_row database'); |
213 |
ok($input, '_load_row input'); |
ok($input, '_load_row input'); |
236 |
); |
); |
237 |
|
|
238 |
ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup'); |
ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup'); |
239 |
diag "_get_lookup = ", dump($l); |
diag "_get_lookup = ", dump($l) if ($debug); |
240 |
|
|
241 |
my @lookup; |
my @lookup; |
242 |
|
|
243 |
ok(@lookup = lookup( |
ok(@lookup = lookup( |
244 |
sub { |
sub { |
245 |
diag "in show"; |
diag "in show" if ($debug); |
246 |
rec('900','x'); |
rec('900','x'); |
247 |
}, |
}, |
248 |
'db','input','key', |
'db','input','key', |
261 |
} |
} |
262 |
|
|
263 |
ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup'); |
ok(my $l = WebPAC::Normalize::_get_lookup(), '_get_lookup'); |
264 |
diag "_get_lookup = ", dump($l); |
diag "_get_lookup = ", dump($l) if ($debug); |
265 |
|
|
266 |
is_deeply( $l, { |
is_deeply( $l, { |
267 |
db => { |
db => { |
281 |
|
|
282 |
####### |
####### |
283 |
|
|
284 |
diag "lookup_hash1 = ", dump($lookup_hash1); |
diag "lookup_hash1 = ", dump($lookup_hash1) if ($debug); |
285 |
ok(_set_lookup( $lookup_hash1 ), '_set_lookup $lookup_hash1'); |
ok(_set_lookup( $lookup_hash1 ), '_set_lookup $lookup_hash1'); |
286 |
|
|
287 |
throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()'; |
throws_ok { _set_load_row() } qr/CODE/, 'empty _set_load_row()'; |
732 |
[ '901', ' ', ' ', 'b', 'bar', 'c', 'baz' ], |
[ '901', ' ', ' ', 'b', 'bar', 'c', 'baz' ], |
733 |
], |
], |
734 |
); |
); |
735 |
|
|
736 |
|
test_s(qq{ marc_remove('*'); }); |
737 |
|
ok(! WebPAC::Normalize::_get_marc_fields(), 'marc_remove(*)'); |
738 |
|
|
739 |
test_rec_rules( |
test_rec_rules( |
740 |
'marc_duplicate', |
'marc_duplicate', |
741 |
{ '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] }, |
{ '200' => [{ a => 42, b => 'bar', c => 'baz', d => 'bing', e => 'bong' }] }, |