/[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 686 by dpavlin, Sun Sep 24 17:25:04 2006 UTC revision 705 by dpavlin, Mon Sep 25 13:46:36 2006 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2    
3  use strict;  use strict;
4  use Test::More tests => 8;  use Test::More tests => 36;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 29  ok( Line 29  ok(
29          my $parser = new WebPAC::Parser(          my $parser = new WebPAC::Parser(
30                  config => new WebPAC::Config( path => $config_path ),                  config => new WebPAC::Config( path => $config_path ),
31                  base_path => $abs_path,                  base_path => $abs_path,
32                    debug => $debug,
33  ), "new");  ), "new");
34    
35  ok($parser->{source}, "source exist");  my $inputs = {
36            foo => [ qw/foo-input1 foo-input2/ ],
37            bar => [ qw/bar-input/ ],
38            baz => [ qw/baz-input/ ],
39    };
40    
41    foreach my $db (keys %$inputs) {
42            ok($parser->valid_database($db), "database $db");
43            ok($inputs->{$db}, "has known inputs");
44            diag "valid inputs = ", dump($inputs->{$db});
45            foreach my $i (@{ $inputs->{$db} }) {
46                    ok($parser->valid_database_input($db,$i), "input $i");
47            }
48    }
49    ok(! $parser->valid_database('non-existant'), "no database");
50    ok(! $parser->valid_database_input('foo','non-existant'), "no database input");
51    
52    ok(my $l = $parser->{_lookup_create}, "_lookup_create");
53    diag "_lookup_create = ",dump($l) if ($debug);
54    foreach my $db (keys %$l) {
55            foreach my $i (keys %{$l->{$db}}) {
56                    foreach my $k (keys %{$l->{$db}->{$i}}) {
57                            ok(defined($parser->lookup_create_rules($db,$i)->{$k}), "have $db/$i/$k");
58                    }
59            }
60    }
61    
62    ok(my $n = $parser->{_normalize_source}, "_normalize_source");
63    diag "_normalize_source = ",dump($n) if ($debug);
64    
65    ok(my $d = $parser->{depends}, "depends");
66    diag "depends = ",dump($d) if ($debug);
67    
68    my $expected_depend = {
69       foo => {
70                "foo-input1" => {
71                                  bar => { "bar-input" => { "210-a-210-e" => 1, "220-a-220-e" => 1, "230-a-230-e" => 1 } },
72                                  baz => { "baz-input" => { "200-a" => 1 } },
73                                  foo => { "foo-input1" => { 11 => 1 }, "foo-input2" => { 11 => 1 } },
74                                },
75                "foo-input2" => {
76                                  bar => { "bar-input" => { "900-x" => 1 } },
77                                  baz => { "baz-input" => { "900-x" => 1 } },
78                                  foo => { "foo-input1" => { "245-a" => 1 }, "foo-input2" => { "245-a" => 1 } },
79                                },
80              },
81       bar => {
82                "bar-input" => {
83                      baz => { "baz-input" => { "900-x" => 1 } },
84                      foo => { "foo-input1" => { "245-a" => 1 } },
85                    },
86              },
87       baz => {
88                "baz-input" => {
89                      bar => { "bar-input" => { "900-x" => 1 } },
90                      foo => { "foo-input2" => { "245-a" => 1 } },
91                    },
92              },
93    };
94    
95    
96    is_deeply($d, $expected_depend, "depends correct");
97    
98    foreach my $db (keys %$d) {
99            foreach my $i (keys %{$d->{$db}}) {
100                    is_deeply($d->{$db}->{$i}, $parser->depends($db,$i), "depend $db/$i");
101            }
102    }
103    
 ok($parser->parse, 'parse');  

Legend:
Removed from v.686  
changed lines
  Added in v.705

  ViewVC Help
Powered by ViewVC 1.1.26