X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=t%2F2-parse.t;h=34a795bdc114ff0d6320429bf7c658eee09e4253;hb=33156dfb36756fcafdf27a56b3254344aab06d09;hp=8f1f334e1426eb175cfaf834dd319648c840f8ec;hpb=ffad59c82cc74a2e31e019769654163c130ec60c;p=webpac2 diff --git a/t/2-parse.t b/t/2-parse.t index 8f1f334..34a795b 100755 --- a/t/2-parse.t +++ b/t/2-parse.t @@ -1,9 +1,9 @@ #!/usr/bin/perl -w use strict; -use blib; +use lib 'lib'; -use Test::More tests => 55; +use Test::More tests => 60; use YAML qw/LoadFile/; @@ -61,7 +61,7 @@ ok(my $n = $parser->{_normalize_source}, "_normalize_source"); diag "_normalize_source = ",dump($n) if ($debug); foreach my $db (keys %$n) { foreach my $i (keys %{$n->{$db}}) { - ok(my $r = $parser->normalize_rules($db,$i), "normalize_source($db/$i)"); + ok(my $r = $parser->normalize_rules($db,$i), "normalize_rules($db/$i)"); diag "normalize_rules($db,$i) = $r" if ($debug); cmp_ok($n->{$db}->{$i}, 'eq', $r, "same"); } @@ -111,7 +111,7 @@ $config_path = "$abs_path/conf/marc.yml"; ok(-e $config_path, "$config_path exists"); ok( - my $parser = new WebPAC::Parser( + $parser = new WebPAC::Parser( config => new WebPAC::Config( path => $config_path ), base_path => $abs_path, %LOG, @@ -132,3 +132,27 @@ is_deeply($marc, { marc_repeatable_subfield => 1, }, 'catched all marc_*'); + +$config_path = "$abs_path/conf/sub.yml"; + +ok(-e $config_path, "$config_path exists"); + +ok( + $parser = new WebPAC::Parser( + config => new WebPAC::Config( path => $config_path ), + base_path => $abs_path, + %LOG, +), "new"); + +ok(my $rules = $parser->normalize_rules('sub','sub-input'), "normalize_rules(sub)"); + +diag "rules: $rules" if $debug; + +our @test; +eval $rules; +diag "test = ",dump( @test ) if $debug; + +ok(! $@, "eval: $@" ); + +is_deeply( [ @test ], [ "foo", "foo", "bar >>2<<", "bar >>42<<", 1,2,3 ], 'source fixed' ); +