mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-16 20:21:01 +01:00
2.37
- "fixed" rt.cpan.org#30199 - check for invalid and unsupported structures, especially mixing blocks and scalars with identical names. - added checks to 'make test' to test for the above checks. - revoked patch of rt.cpan.org#27225, it broke running code. - fixed rt.cpan.org#30063 (and #27225!) by reimplementing the whole interpolation code. The internal stack is no more a class variable of the module but stored directly within the generated config hash and cleaned before returning to the user. - added (modified) patch rt.cpan.org#30063 to check if interpolation works with supplied default config works. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@63 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
13
t/cfg.39
Normal file
13
t/cfg.39
Normal file
@@ -0,0 +1,13 @@
|
||||
<outer b1>
|
||||
test = foo
|
||||
<inner>
|
||||
ivar = $test
|
||||
</inner>
|
||||
</outer>
|
||||
|
||||
<outer b2>
|
||||
test = bar
|
||||
<inner>
|
||||
ivar = $test
|
||||
</inner>
|
||||
</outer>
|
||||
7
t/cfg.40
Normal file
7
t/cfg.40
Normal file
@@ -0,0 +1,7 @@
|
||||
# should generate an error about invalid structure
|
||||
# array of scalars => hashref
|
||||
val = 1
|
||||
val = 2
|
||||
<val 3>
|
||||
x = no
|
||||
</val>
|
||||
6
t/cfg.41
Normal file
6
t/cfg.41
Normal file
@@ -0,0 +1,6 @@
|
||||
# should generate an error about invalid structure
|
||||
# scalar => hashref
|
||||
val = 1
|
||||
<val 2>
|
||||
x = no
|
||||
</val>
|
||||
13
t/cfg.42
Normal file
13
t/cfg.42
Normal file
@@ -0,0 +1,13 @@
|
||||
# should generate an error about invalid structure
|
||||
# array of hashrefs => scalar
|
||||
|
||||
<val 1>
|
||||
x = no
|
||||
</val>
|
||||
|
||||
val = 3
|
||||
|
||||
<val 2>
|
||||
x = no
|
||||
</val>
|
||||
|
||||
5
t/cfg.43
Normal file
5
t/cfg.43
Normal file
@@ -0,0 +1,5 @@
|
||||
# should generate an error about invalid structure
|
||||
val = 1
|
||||
<val>
|
||||
x = 2
|
||||
</val>
|
||||
35
t/run.t
35
t/run.t
@@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
use Data::Dumper;
|
||||
use Test::More tests => 38;
|
||||
use Test::More tests => 43;
|
||||
#use Test::More qw(no_plan);
|
||||
|
||||
### 1
|
||||
@@ -117,16 +117,25 @@ else {
|
||||
}
|
||||
|
||||
|
||||
|
||||
### 17
|
||||
# testing value pre-setting using a hash
|
||||
my $conf17 = new Config::General(
|
||||
-file => "t/cfg.17",
|
||||
-DefaultConfig => { home => "/exports/home", logs => "/var/backlog" },
|
||||
-DefaultConfig => { home => "/exports/home",
|
||||
logs => "/var/backlog",
|
||||
foo => {
|
||||
bar => "quux"
|
||||
}
|
||||
},
|
||||
-InterPolateVars => 1,
|
||||
-MergeDuplicateOptions => 1,
|
||||
-MergeDuplicateBlocks => 1
|
||||
);
|
||||
my %h17 = $conf17->getall();
|
||||
ok ($h17{home} eq "/home/users", "Testing value pre-setting using a hash");
|
||||
ok ($h17{home} eq "/home/users" &&
|
||||
$h17{foo}{quux} eq "quux",
|
||||
"Testing value pre-setting using a hash");
|
||||
|
||||
|
||||
### 18
|
||||
@@ -404,7 +413,7 @@ my %C36 = $conf36->getall;
|
||||
is_deeply( \%C36, { bit => { one => { honk=>'bonk' },
|
||||
two => { honk=>'bonk' }
|
||||
} }, "Included twice" );
|
||||
|
||||
|
||||
|
||||
### Include once
|
||||
diag "\nPlease ignore the following message about IncludeAgain";
|
||||
@@ -423,3 +432,21 @@ my %C38 = $conf38->getall;
|
||||
is_deeply( \%C38, { bit => { one => { honk=>'bonk' },
|
||||
two => { honk=>'bonk' }
|
||||
} }, "Apache-style include" );
|
||||
|
||||
#### 39 verifies bug rt#27225
|
||||
# testing variable scope.
|
||||
# a variable shall resolve to the value defined in the current
|
||||
# scope, not a previous outer scope.
|
||||
my $conf39 = new Config::General(-ConfigFile => "t/cfg.39", -InterPolateVars => 1, -StrictVars => 0);
|
||||
my %conf39 = $conf39->getall();
|
||||
isnt($conf39{outer}->{b1}->{inner}->{ivar},
|
||||
$conf39{outer}->{b2}->{inner}->{ivar},
|
||||
"Variable scope test");
|
||||
|
||||
### 40 - 42 verify if structural error checks are working
|
||||
foreach my $pos (40 .. 43) {
|
||||
eval {
|
||||
my $conf = new Config::General(-ConfigFile => "t/cfg.$pos");
|
||||
};
|
||||
ok($@ =~ /^Config::General/, "$pos: Structural error checks");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user