- "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:
Thomas von Dein
2009-10-10 16:42:58 +00:00
parent c2a51ca15f
commit f85e18462c
11 changed files with 266 additions and 145 deletions

View File

@@ -1 +1,4 @@
home = /home/users
<foo>
quux = $bar
</foo>

13
t/cfg.39 Normal file
View 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
View 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
View 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
View 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
View File

@@ -0,0 +1,5 @@
# should generate an error about invalid structure
val = 1
<val>
x = 2
</val>

35
t/run.t
View File

@@ -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");
}