2 |
|
|
3 |
use strict; |
use strict; |
4 |
|
|
5 |
use Test::More tests => 66; |
use Test::More tests => 41; |
6 |
use Test::Exception; |
use Test::Exception; |
7 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
8 |
use File::Temp qw/tempdir/; |
use File::Temp qw/tempdir/; |
9 |
use File::Slurp; |
use File::Slurp; |
10 |
use Data::Dumper; |
use Data::Dumper; |
11 |
|
use Time::HiRes qw/time/; |
12 |
use blib; |
use blib; |
13 |
|
|
14 |
my $debug = shift @ARGV; |
my $debug = shift @ARGV; |
35 |
my $normalize_set_pl = "$abs_path/data/normalize.pl"; |
my $normalize_set_pl = "$abs_path/data/normalize.pl"; |
36 |
my $lookup_file = "$abs_path../conf/lookup/isis.pm"; |
my $lookup_file = "$abs_path../conf/lookup/isis.pm"; |
37 |
|
|
38 |
|
my ($t1,$t2) = (0,0); |
39 |
|
|
40 |
ok(my $lookup = new WebPAC::Lookup( |
ok(my $lookup = new WebPAC::Lookup( |
41 |
lookup_file => $lookup_file, |
lookup_file => $lookup_file, |
42 |
), "new Lookup"); |
), "new Lookup"); |
44 |
ok(my $isis = new WebPAC::Input( |
ok(my $isis = new WebPAC::Input( |
45 |
module => 'WebPAC::Input::ISIS', |
module => 'WebPAC::Input::ISIS', |
46 |
code_page => 'ISO-8859-2', # application encoding |
code_page => 'ISO-8859-2', # application encoding |
47 |
limit => 10, |
limit => 100, |
48 |
|
no_progress_bar => 1, |
49 |
), "new Input::ISIS"); |
), "new Input::ISIS"); |
50 |
|
|
51 |
ok(my $maxmfn = $isis->open( |
ok(my $maxmfn = $isis->open( |
66 |
db => $db, |
db => $db, |
67 |
lookup_regex => $lookup->regex, |
lookup_regex => $lookup->regex, |
68 |
lookup => $lookup, |
lookup => $lookup, |
69 |
|
no_progress_bar => 1, |
70 |
), "new Normalize::XML"); |
), "new Normalize::XML"); |
71 |
|
|
72 |
ok($n->open( |
ok($n->open( |
83 |
|
|
84 |
diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug); |
diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug); |
85 |
|
|
86 |
while (my $row = $isis->fetch) { |
foreach my $pos ( 0 ... $isis->size ) { |
87 |
|
|
88 |
|
my $row = $isis->fetch || next; |
89 |
|
|
90 |
diag " row => ",Dumper($row) if ($debug); |
diag " row $pos => ",Dumper($row) if ($debug); |
|
set_rec( $row ); |
|
91 |
|
|
92 |
ok(my $ds = $n->data_structure($row), "data_structure"); |
my $t = time(); |
93 |
|
ok(my $ds = $n->data_structure($row), "XML data_structure"); |
94 |
|
$t1 += time() - $t; |
95 |
|
|
96 |
diag " ds => ",Dumper($ds) if ($debug); |
diag " ds $pos => ",Dumper($ds) if ($debug); |
97 |
|
|
98 |
# TODO move somewhere |
$t = time(); |
99 |
{ |
ok( my $ds2 = WebPAC::Normalize::Set::data_structure( |
100 |
no strict 'subs'; |
lookup => $lookup->lookup_hash, |
101 |
use WebPAC::Normalize::Set; |
row => $row, |
102 |
set_lookup( $lookup->lookup_hash ); |
rules => $norm_pl, |
103 |
clean_ds(); |
), "Set data_structure"); |
104 |
eval "$norm_pl"; |
$t2 += time() - $t; |
|
ok(! $@, $@ ? "error: $@" : "no error"); |
|
|
ok(my $ds2 = get_ds(), "get_ds"); |
|
|
is_deeply( $ds, $ds2, 'ds same for xml and sets'); |
|
105 |
|
|
106 |
diag " ds2 => ",Dumper($ds2) if ($debug); |
diag " ds2 $pos => ",Dumper($ds2) if ($debug); |
107 |
} |
is_deeply( $ds, $ds2, 'ds same for xml and sets'); |
108 |
|
|
109 |
ok(my $html = $out->apply( |
ok(my $html = $out->apply( |
110 |
template => 'html.tt', |
template => 'html.tt', |
116 |
#diag $html; |
#diag $html; |
117 |
|
|
118 |
}; |
}; |
119 |
|
|
120 |
|
diag sprintf("timings: %.2fs vs %.2fs [%1.2f%%]\n", $t1, $t2, ($t1 / $t2) * 100); |