1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use Test::More tests => 108; |
use Test::More tests => 111; |
4 |
use Test::Exception; |
use Test::Exception; |
5 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
6 |
use blib; |
use blib; |
134 |
|
|
135 |
$WebPAC::Input::Test::size = 42; |
$WebPAC::Input::Test::size = 42; |
136 |
|
|
137 |
ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)"); |
ok($input->open( path => "/fake/path", ), "open modify_isis (plain)"); |
138 |
|
|
139 |
cmp_ok($input->size, '==', 42, 'size'); |
cmp_ok($input->size, '==', 42, 'size'); |
140 |
|
|
143 |
# modify_records |
# modify_records |
144 |
|
|
145 |
ok($input->open( |
ok($input->open( |
146 |
path => "$abs_path/modify_isis/LIBRI", |
path => "/another/fake/path", |
147 |
modify_records => { |
modify_records => { |
148 |
200 => { |
200 => { |
149 |
'*' => { '^c' => '. ' }, |
'*' => { '^c' => '. ' }, |
170 |
my $modify_file = "$abs_path/conf/modify/test.pl"; |
my $modify_file = "$abs_path/conf/modify/test.pl"; |
171 |
|
|
172 |
ok($input->open( |
ok($input->open( |
173 |
path => "$abs_path/modify_isis/LIBRI", |
path => "/and/another/fake/path", |
174 |
modify_file => $modify_file, |
modify_file => $modify_file, |
175 |
), "open (with modify_file $modify_file)"); |
), "open (with modify_file $modify_file)"); |
176 |
|
|
177 |
my $f = $WebPAC::Input::Test::filter_coderef; |
my $f = $WebPAC::Input::Test::filter_coderef; |
178 |
ok(ref($f) eq 'CODE', 'filter_coderef'); |
ok(ref($f) eq 'CODE', 'filter_coderef'); |
179 |
|
|
180 |
diag "regexps = ", dump($input->modify_file_regexps( $modify_file )); |
diag "regexps = ", dump($input->modify_file_regexps( $modify_file )) if ($debug); |
181 |
|
|
182 |
sub test_filter { |
sub test_filter { |
183 |
my ($field, $from, $to) = @_; |
my ($field, $from, $to) = @_; |
186 |
|
|
187 |
test_filter(200, |
test_filter(200, |
188 |
'^a foo ; bar = baz : zzz', |
'^a foo ; bar = baz : zzz', |
189 |
'^a foo^kbar^dbaz^ezzz', |
'^a foo^kbar^dbaz : zzz', |
190 |
); |
); |
191 |
|
|
192 |
|
# empty subfield removal |
193 |
|
test_filter(901, |
194 |
|
'^a^efoo', |
195 |
|
'^efoo', |
196 |
|
); |