/[webpac2]/trunk/t/2-parse.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/2-parse.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1060 by dpavlin, Thu Nov 1 00:16:48 2007 UTC revision 1061 by dpavlin, Tue Nov 20 22:07:45 2007 UTC
# Line 3  Line 3 
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    
# Line 61  ok(my $n = $parser->{_normalize_source}, Line 61  ok(my $n = $parser->{_normalize_source},
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          }          }
# Line 111  $config_path = "$abs_path/conf/marc.yml" Line 111  $config_path = "$abs_path/conf/marc.yml"
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,
# Line 132  is_deeply($marc, { Line 132  is_deeply($marc, {
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    

Legend:
Removed from v.1060  
changed lines
  Added in v.1061

  ViewVC Help
Powered by ViewVC 1.1.26