2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 25; |
use Test::More tests => 42; |
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::Dumper; |
12 |
my $debug = 0; |
my $debug = shift @ARGV; |
13 |
|
|
14 |
BEGIN { |
BEGIN { |
15 |
use_ok( 'WebPAC::Normalize::Set' ); |
use_ok( 'WebPAC::Normalize::Set' ); |
208 |
ok(my $ds = get_ds(), "get_ds"); |
ok(my $ds = get_ds(), "get_ds"); |
209 |
diag "ds = ", Dumper($ds) if ($debug); |
diag "ds = ", Dumper($ds) if ($debug); |
210 |
|
|
|
clean_ds(); |
|
211 |
|
|
212 |
|
sub test_check_ds { |
213 |
|
|
214 |
|
my $t = shift; |
215 |
|
|
216 |
|
ok($ds = get_ds(), 'get_ds'); |
217 |
|
diag Dumper( $ds ) if ($debug); |
218 |
|
|
219 |
|
ok( $ds && $ds->{something}, 'get_ds->something exists' ); |
220 |
|
ok( $ds && $ds->{something}->{$t}, 'get_ds->something->'.$t.' exists') if ($t); |
221 |
|
ok( $ds && !$ds->{empty}, 'get_ds->empty doesn\'t' ); |
222 |
|
|
223 |
|
return $ds; |
224 |
|
} |
225 |
|
|
226 |
|
clean_ds(); |
227 |
test_s(qq{ search('something', '42'); }); |
test_s(qq{ search('something', '42'); }); |
228 |
test_s(qq{ search('empty', ''); }); |
test_s(qq{ search('empty', ''); }); |
229 |
|
test_check_ds('search'); |
230 |
|
|
231 |
ok($ds = get_ds(), 'get_ds'); |
clean_ds(); |
232 |
diag Dumper( $ds ) if ($debug); |
test_s(qq{ display('something', '42'); }); |
233 |
|
test_s(qq{ display('empty', ''); }); |
234 |
ok( $ds && $ds->{something}, 'get_ds->something' ); |
test_check_ds('display'); |
|
ok( $ds && !$ds->{empty}, 'get_ds->empty' ); |
|
235 |
|
|
236 |
clean_ds(); |
clean_ds(); |
237 |
|
test_s(qq{ tag('something', '42'); }); |
238 |
|
test_s(qq{ tag('empty', ''); }); |
239 |
|
test_check_ds('search'); |
240 |
|
test_check_ds('display'); |
241 |
|
|
242 |
|
clean_ds(); |
243 |
my $n = read_file( "$abs_path/data/normalize.pl" ); |
my $n = read_file( "$abs_path/data/normalize.pl" ); |
244 |
$n .= "\n1;\n"; |
$n .= "\n1;\n"; |
245 |
#diag "normalize code:\n$n\n"; |
#diag "normalize code:\n$n\n"; |