5 BEGIN {plan tests => 24};
11 $dir =~ tr|\\|/|; # should probably use File::Spec
13 $dir = '.' if ! length $dir;
15 my $obj = CGI::Ex::Conf->new({
16 paths => ["$dir/conf_path_1", "$dir/conf_path_3"],
19 ### most test for the reading of files
20 ### are actually performed in the validation tests
24 my $hash = $obj->read('apples.pl');
26 ok($hash->{quantity});
28 $hash = $obj->read('apples.pl');
30 ok($hash->{quantity});
33 local $CGI::Ex::Conf::DIRECTIVE = 'FIRST';
34 $hash = $obj->read('apples.pl');
36 ok($hash->{quantity} == 20);
37 ok($hash->{foo} eq 'file1');
39 local $CGI::Ex::Conf::DIRECTIVE = 'LAST';
40 $hash = $obj->read('apples.pl');
42 ok($hash->{quantity} == 30);
43 ok($hash->{foo} eq 'file2');
45 $hash = $obj->read('apples.pl', {directive => 'MERGE'});
47 ok($hash->{quantity} == 30);
48 ok($hash->{foo} eq 'file1'); # has immutable value
51 local $obj->{directive} = 'FIRST';
52 $hash = $obj->read('oranges.pl');
54 ok($hash->{quantity} == 20);
55 ok($hash->{foo} eq 'file1');
57 local $obj->{directive} = 'LAST';
58 $hash = $obj->read('oranges.pl');
60 ok($hash->{quantity} == 30);
61 ok($hash->{foo} eq 'file2');
63 local $obj->{directive} = 'MERGE';
64 $hash = $obj->read('oranges.pl');
66 ok($hash->{quantity} == 20); # has immutable key so all values are immutable
67 ok($hash->{foo} eq 'file1'); # has immutable key so all values are immutable