/[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 687 by dpavlin, Sun Sep 24 17:49:05 2006 UTC revision 706 by dpavlin, Mon Sep 25 14:06:49 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 => 43;
5  use Test::Exception;  use Test::Exception;
6  use blib;  use blib;
7    
# Line 32  ok( Line 32  ok(
32                  debug => $debug,                  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_key}, "_lookup_create_key");
53    ok($parser->{_lookup_create}, "_lookup_create");
54    diag "_lookup_create_key = ",dump($l) if ($debug);
55    foreach my $db (keys %$l) {
56            foreach my $i (keys %{$l->{$db}}) {
57                    ok(defined($parser->lookup_create_rules($db,$i)), "have $db/$i");
58                    my @keys = sort keys %{$l->{$db}->{$i}};
59                    ok(@keys, 'have keys');
60                    my @have_keys = sort $parser->have_lookup_create($db,$i);
61                    ok(@have_keys, 'have_lookup_create');
62                    ok(eq_array(\@have_keys, \@keys), "found all lookups");
63            }
64    }
65    
66    ok(my $n = $parser->{_normalize_source}, "_normalize_source");
67    diag "_normalize_source = ",dump($n) if ($debug);
68    
69    ok(my $d = $parser->{depends}, "depends");
70    diag "depends = ",dump($d) if ($debug);
71    
72    my $expected_depend = {
73       foo => {
74                "foo-input1" => {
75                                  bar => { "bar-input" => { "210-a-210-e" => 1, "220-a-220-e" => 1, "230-a-230-e" => 1 } },
76                                  baz => { "baz-input" => { "200-a" => 1 } },
77                                  foo => { "foo-input1" => { 11 => 1 }, "foo-input2" => { 11 => 1 } },
78                                },
79                "foo-input2" => {
80                                  bar => { "bar-input" => { "900-x" => 1 } },
81                                  baz => { "baz-input" => { "900-x" => 1 } },
82                                  foo => { "foo-input1" => { "245-a" => 1 }, "foo-input2" => { "245-a" => 1 } },
83                                },
84              },
85       bar => {
86                "bar-input" => {
87                      baz => { "baz-input" => { "900-x" => 1 } },
88                      foo => { "foo-input1" => { "245-a" => 1 } },
89                    },
90              },
91       baz => {
92                "baz-input" => {
93                      bar => { "bar-input" => { "900-x" => 1 } },
94                      foo => { "foo-input2" => { "245-a" => 1 } },
95                    },
96              },
97    };
98    
99    
100    is_deeply($d, $expected_depend, "depends correct");
101    
102    foreach my $db (keys %$d) {
103            foreach my $i (keys %{$d->{$db}}) {
104                    is_deeply($d->{$db}->{$i}, $parser->depends($db,$i), "depend $db/$i");
105            }
106    }
107    
 ok($parser->parse, 'parse');  

Legend:
Removed from v.687  
changed lines
  Added in v.706

  ViewVC Help
Powered by ViewVC 1.1.26