fixed rt.cpan.org#113671: recognize BOM at start of a utf8 file

fixed rt.cpan.org#112857: Same Line Closing Block Breaks Parser



git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@110 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2016-04-18 13:09:45 +00:00
parent 34397e9b04
commit 7a48e048cf
6 changed files with 281 additions and 244 deletions

17
t/run.t
View File

@@ -8,7 +8,7 @@
use Data::Dumper;
use Test::More tests => 73;
use Test::More tests => 75;
#use Test::More qw(no_plan);
# ahem, we deliver the test code with a local copy of
@@ -18,7 +18,7 @@ use lib qw(t);
use Tie::IxHash;
my @WARNINGS_FOUND;
BEGIN {
$SIG{__WARN__} = sub { diag( "WARN: ", join( '', @_ ) ); push @WARNINGS_FOUND, @_ };
$SIG{__WARN__} = sub { diag( "WARN: ", join( '', @_ ) ); push @WARNINGS_FOUND, @_ };
}
### 1
@@ -761,3 +761,16 @@ eval {
$cfg56->save_file("t/56.out", { "new\nline" => 9, "brack<t" => 8 });
};
ok($@, "catch special chars in keys");
# UTF8[BOM] tests
my $cfg57 = "t/utf8_bom/foo.cfg";
my $expected57 = {foo => {"\x{e9}" => "\x{e8}", bar => {"\x{f4}" => "\x{ee}"}}};
for my $bool (0, 1) {
my $conf = Config::General->new(-ConfigFile => $cfg57,
-IncludeRelative => 1,
-UTF8 => $bool);
my %hash = $conf->getall;
is_deeply \%hash, $expected57, "-UTF8 => $bool";
}

3
t/utf8_bom/bar.cfg Normal file
View File

@@ -0,0 +1,3 @@
<bar>
ô = î
</bar>

4
t/utf8_bom/foo.cfg Normal file
View File

@@ -0,0 +1,4 @@
<foo>
é = è
<<include bar.cfg>>
</foo>