Locale-TextDomain-OO-Extract-Xslate
view release on metacpan or search on metacpan
t/10-kolon.t view on Meta::CPAN
is_deeply( $got, $expected, "Succesful extraction from Kolon syntax templates with standard methods and filters" )
or warn Dumper $got;
# separate test for custom user-provided function names
# with a couple of the original ones still in there just to check
$extract = Locale::TextDomain::OO::Extract::Xslate->new();
$expected = {
'i-default::' => {
'' => {
'msgstr' => {
'nplurals' => 2,
'plural' => 'n != 1'
}
},
'Page title' => { 'reference' => { 't/data/kolon/custom.tx:5' => undef, } },
'Just some text' => { 'reference' => { 't/data/kolon/custom.tx:2' => undef, } },
"Text with {variable}.\x{04}some context" => { 'reference' => { 't/data/kolon/custom.tx:19' => undef, } },
"Text with umlauts: \x{e4}\x{f6}\x{fc}\x{df}." => {
'reference' => {
't/data/kolon/custom.tx:17' => undef,
't/data/kolon/custom.tx:18' => undef,
}
},
'Book named \'Moby Dick\'.' => { 'reference' => { 't/data/kolon/custom.tx:14' => undef, } },
},
};
for my $file ( map { path( $_ ) } 't/data/kolon/custom.tx' ) {
my $fn = $file->relative( q{./} )->stringify;
$extract->clear;
$extract->filename( $fn );
# add our additional l10n functions
$extract->addl_l10n_function_re( qr{ loc | i10n_me | whatever }x );
$extract->extract;
}
my $got = $extract->lexicon_ref;
is_deeply( $got, $expected, "Succesful extraction from Kolon syntax templates with custom methods" )
or warn Dumper $got;
# separate test for __($a_variable) warning bug,
# separate so I don't have to change the line numbers in the existing ones
{
my @warnings;
local $SIG{__WARN__} = sub { print STDERR @_; push @warnings, @_ };
$extract = Locale::TextDomain::OO::Extract::Xslate->new( debug => 0 );
$expected = {};
for my $file ( map { path( $_ ) } 't/data/kolon/a_variable.tx' ) {
my $fn = $file->relative( q{./} )->stringify;
$extract->clear;
$extract->filename( $fn );
$extract->extract;
}
my $got = $extract->lexicon_ref;
is_deeply( $got, $expected, "Succesful extraction from Kolon syntax templates with __(\$foo)" )
or warn Dumper $got;
is scalar @warnings, 0, "No warnings from __(\$foo) stuff"
or warn "warnings: @warnings";
}
# separate test for :cascade
{
$extract = Locale::TextDomain::OO::Extract::Xslate->new();
$expected = {
'i-default::' => {
'' => {
'msgstr' => {
'plural' => 'n != 1',
'nplurals' => 2
}
},
'The macro says: ' => { 'reference' => { 't/data/kolon/cascade/helpers.tx:1' => undef } },
'My Template!' => { 'reference' => { 't/data/kolon/cascade/base.tx:4' => undef } },
'My template body!' => { 'reference' => { 't/data/kolon/cascade/foo.tx:4' => undef } }
}
};
@files = (
qw(
t/data/kolon/cascade/helpers.tx
t/data/kolon/cascade/base.tx
t/data/kolon/cascade/foo.tx
)
);
for my $file ( map { path( $_ ) } @files ) {
my $fn = $file->relative( q{./} )->stringify;
$extract->clear;
$extract->filename( $fn );
$extract->extract;
}
my $got = $extract->lexicon_ref;
is_deeply( $got, $expected, "Succesful extraction from Kolon syntax templates with :cascade" )
or warn Dumper $got;
}
# separate test for <: if $x = nil :> warning bug,
{
my @warnings;
local $SIG{__WARN__} = sub { print STDERR @_; push @warnings, @_ };
$extract = Locale::TextDomain::OO::Extract::Xslate->new( debug => 0 );
$expected = {};
for my $file ( map { path( $_ ) } 't/data/kolon/nil.tx' ) {
my $fn = $file->relative( q{./} )->stringify;
$extract->clear;
$extract->filename( $fn );
$extract->extract;
}
my $got = $extract->lexicon_ref;
is_deeply( $got, $expected, "Succesful extraction from Kolon syntax templates with nil" )
or warn Dumper $got;
is scalar @warnings, 0, "No warnings from 'nil'"
or warn "warnings: @warnings";
}
done_testing;
( run in 3.326 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )