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 => 26; |
5 |
use Test::Exception; |
use Test::Exception; |
6 |
use blib; |
use blib; |
7 |
|
|
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}, "_lookup_create"); |
53 |
|
diag "_lookup_create = ",dump($l); |
54 |
|
|
55 |
ok($parser->parse, 'parse'); |
ok(my $n = $parser->{_normalize_source}, "_normalize_source"); |
56 |
|
diag "_normalize_source = ",dump($n); |
57 |
|
|
58 |
|
ok(my $d = $parser->{depends}, "depends"); |
59 |
|
diag "depends = ",dump($d); |
60 |
|
|
61 |
|
my $expected_depend = { |
62 |
|
foo => { |
63 |
|
"foo-input1" => { |
64 |
|
bar => { "bar-input" => "200-a-200-e" }, |
65 |
|
baz => { "baz-input" => "200-a" }, |
66 |
|
foo => { "foo-input1" => 11, "foo-input2" => 11 }, |
67 |
|
}, |
68 |
|
"foo-input2" => { |
69 |
|
bar => { "bar-input" => "200-a-200-e" }, |
70 |
|
baz => { "baz-input" => "200-a" }, |
71 |
|
foo => { "foo-input1" => 11, "foo-input2" => 11 }, |
72 |
|
}, |
73 |
|
}, |
74 |
|
bar => { "bar-input" => { foo => { "foo-input1" => "245-a" } } }, |
75 |
|
baz => { "baz-input" => { baz => { "baz-input" => "900-x" } } }, |
76 |
|
}; |
77 |
|
|
78 |
|
|
79 |
|
is_deeply($d, $expected_depend, "depends correct"); |
80 |
|
|
81 |
|
foreach my $db (keys %$d) { |
82 |
|
foreach my $i (keys %{$d->{$db}}) { |
83 |
|
is_deeply($d->{$db}->{$i}, $parser->depends($db,$i), "depend $db/$i"); |
84 |
|
} |
85 |
|
} |