projects
/
webpac2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r1898@llin: dpavlin | 2009-05-29 22:55:52 +0200
[webpac2]
/
t
/
6-unit.t
diff --git
a/t/6-unit.t
b/t/6-unit.t
index
5658ce6
..
a9a6935
100755
(executable)
--- a/
t/6-unit.t
+++ b/
t/6-unit.t
@@
-2,22
+2,24
@@
use strict;
use strict;
-use Test::More tests =>
24
;
+use Test::More tests =>
31
;
use Test::Exception;
use Cwd qw/abs_path/;
use File::Temp qw/tempdir/;
use File::Slurp;
use Test::Exception;
use Cwd qw/abs_path/;
use File::Temp qw/tempdir/;
use File::Slurp;
-use Data::Dump
er
;
+use Data::Dump
qw/dump/
;
use Time::HiRes qw/time/;
use blib;
my $debug = shift @ARGV;
use Time::HiRes qw/time/;
use blib;
my $debug = shift @ARGV;
+#
+# FIXME add lookup testing!
+#
+
BEGIN {
BEGIN {
-use_ok( 'WebPAC::Lookup' );
use_ok( 'WebPAC::Input' );
use_ok( 'WebPAC::Store' );
use_ok( 'WebPAC::Input' );
use_ok( 'WebPAC::Store' );
-use_ok( 'WebPAC::Lookup::Normalize' );
use_ok( 'WebPAC::Normalize' );
use_ok( 'WebPAC::Output::TT' );
}
use_ok( 'WebPAC::Normalize' );
use_ok( 'WebPAC::Output::TT' );
}
@@
-35,29
+37,27
@@
diag "isis_file: $isis_file" if ($debug);
my $normalize_set_pl = "$abs_path/data/normalize.pl";
my $lookup_file = "$abs_path../conf/lookup/isis.pm";
my $normalize_set_pl = "$abs_path/data/normalize.pl";
my $lookup_file = "$abs_path../conf/lookup/isis.pm";
-ok(my $lookup = new WebPAC::Lookup(
- lookup_file => $lookup_file,
-), "new Lookup");
-
ok(my $isis = new WebPAC::Input(
module => 'WebPAC::Input::ISIS',
ok(my $isis = new WebPAC::Input(
module => 'WebPAC::Input::ISIS',
- code_page => 'ISO-8859-2', # application encoding
limit => 100,
no_progress_bar => 1,
), "new Input::ISIS");
ok(my $maxmfn = $isis->open(
path => $isis_file,
limit => 100,
no_progress_bar => 1,
), "new Input::ISIS");
ok(my $maxmfn = $isis->open(
path => $isis_file,
- code_page => '852', # database encoding
- lookup => $lookup,
+ input_encoding => 'cp852', # database encoding
+ lookup_coderef => sub {
+ my $rec = shift || return;
+ ok($rec, 'lookup_coderef has rec');
+ ok(defined($rec->{'000'}->[0]), 'have mfn');
+ },
), "Input::ISIS->open");
ok(my $path = tempdir( CLEANUP => 1 ), "path");
), "Input::ISIS->open");
ok(my $path = tempdir( CLEANUP => 1 ), "path");
-ok(my $db = new WebPAC::Store(
- path => $path,
+ok(my $db = new WebPAC::Store({
database => '.',
database => '.',
-), "new Store");
+
}
), "new Store");
ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
ok(my $norm_pl = read_file( $normalize_set_pl ), "set definitions: $normalize_set_pl" );
@@
-66,25
+66,22
@@
ok(my $out = new WebPAC::Output::TT(
filters => { foo => sub { shift } },
), "new Output::TT");
filters => { foo => sub { shift } },
), "new Output::TT");
-diag " lookup => ",Dumper($lookup->lookup_hash) if ($debug);
-
my $t_norm = 0;
foreach my $pos ( 0 ... $isis->size ) {
my $row = $isis->fetch || next;
my $t_norm = 0;
foreach my $pos ( 0 ... $isis->size ) {
my $row = $isis->fetch || next;
- diag " row $pos => ",
Dumper
($row) if ($debug);
+ diag " row $pos => ",
dump
($row) if ($debug);
my $t = time();
ok( my $ds = WebPAC::Normalize::data_structure(
my $t = time();
ok( my $ds = WebPAC::Normalize::data_structure(
- lookup => $lookup->lookup_hash,
row => $row,
rules => $norm_pl,
), "Set data_structure");
$t_norm += time() - $t;
row => $row,
rules => $norm_pl,
), "Set data_structure");
$t_norm += time() - $t;
- diag " ds $pos => ",
Dumper
($ds) if ($debug);
+ diag " ds $pos => ",
dump
($ds) if ($debug);
ok(my $html = $out->apply(
template => 'html.tt',
ok(my $html = $out->apply(
template => 'html.tt',