--- trunk/t/2-parse.t 2007/11/20 10:10:37 1060 +++ trunk/t/2-parse.t 2007/11/20 22:07:45 1061 @@ -3,7 +3,7 @@ use strict; use blib; -use Test::More tests => 55; +use Test::More tests => 60; use YAML qw/LoadFile/; @@ -61,7 +61,7 @@ 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 @@ 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 @@ 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<<" ], 'sub executed' ); +