3 |
use strict; |
use strict; |
4 |
use blib; |
use blib; |
5 |
|
|
6 |
use Test::More tests => 55; |
use Test::More tests => 60; |
7 |
|
|
8 |
use YAML qw/LoadFile/; |
use YAML qw/LoadFile/; |
9 |
|
|
61 |
diag "_normalize_source = ",dump($n) if ($debug); |
diag "_normalize_source = ",dump($n) if ($debug); |
62 |
foreach my $db (keys %$n) { |
foreach my $db (keys %$n) { |
63 |
foreach my $i (keys %{$n->{$db}}) { |
foreach my $i (keys %{$n->{$db}}) { |
64 |
ok(my $r = $parser->normalize_rules($db,$i), "normalize_source($db/$i)"); |
ok(my $r = $parser->normalize_rules($db,$i), "normalize_rules($db/$i)"); |
65 |
diag "normalize_rules($db,$i) = $r" if ($debug); |
diag "normalize_rules($db,$i) = $r" if ($debug); |
66 |
cmp_ok($n->{$db}->{$i}, 'eq', $r, "same"); |
cmp_ok($n->{$db}->{$i}, 'eq', $r, "same"); |
67 |
} |
} |
111 |
ok(-e $config_path, "$config_path exists"); |
ok(-e $config_path, "$config_path exists"); |
112 |
|
|
113 |
ok( |
ok( |
114 |
my $parser = new WebPAC::Parser( |
$parser = new WebPAC::Parser( |
115 |
config => new WebPAC::Config( path => $config_path ), |
config => new WebPAC::Config( path => $config_path ), |
116 |
base_path => $abs_path, |
base_path => $abs_path, |
117 |
%LOG, |
%LOG, |
132 |
marc_repeatable_subfield => 1, |
marc_repeatable_subfield => 1, |
133 |
}, 'catched all marc_*'); |
}, 'catched all marc_*'); |
134 |
|
|
135 |
|
|
136 |
|
$config_path = "$abs_path/conf/sub.yml"; |
137 |
|
|
138 |
|
ok(-e $config_path, "$config_path exists"); |
139 |
|
|
140 |
|
ok( |
141 |
|
$parser = new WebPAC::Parser( |
142 |
|
config => new WebPAC::Config( path => $config_path ), |
143 |
|
base_path => $abs_path, |
144 |
|
%LOG, |
145 |
|
), "new"); |
146 |
|
|
147 |
|
ok(my $rules = $parser->normalize_rules('sub','sub-input'), "normalize_rules(sub)"); |
148 |
|
|
149 |
|
diag "rules: $rules" if $debug; |
150 |
|
|
151 |
|
our @test; |
152 |
|
eval $rules; |
153 |
|
diag "test = ",dump( @test ) if $debug; |
154 |
|
|
155 |
|
ok(! $@, "eval: $@" ); |
156 |
|
|
157 |
|
is_deeply( [ @test ], [ "foo", "foo", "bar >>2<<", "bar >>42<<" ], 'sub executed' ); |
158 |
|
|