1 use Test::More tests => 11;
5 unshift @INC, qw(lib ../lib);
6 use_ok('Locale::Maketext');
11 @MyTestLocale::ISA = qw(Locale::Maketext);
12 %MyTestLocale::Lexicon = ();
13 %MyTestLocale::Lexicon = (); # to avoid warnings
15 package MyTestLocale::fr;
17 @MyTestLocale::fr::ISA = qw(MyTestLocale);
19 %MyTestLocale::fr::Lexicon = (
21 'Hello World' => 'Bonjour Monde',
26 my $lh = MyTestLocale->get_handle('fr');
27 $lh->{'use_external_lex_cache'} = 1;
28 ok(exists $MyTestLocale::fr::Lexicon{'Hello World'} && !ref $MyTestLocale::fr::Lexicon{'Hello World'}, 'lex value not a ref');
30 is($lh->maketext('Hello World'), 'Bonjour Monde', 'renders correctly first time');
31 ok(exists $lh->{'_external_lex_cache'}{'Hello World'} && ref $lh->{'_external_lex_cache'}{'Hello World'}, 'compiled into lex_cache');
32 ok(exists $MyTestLocale::fr::Lexicon{'Hello World'} && !ref $MyTestLocale::fr::Lexicon{'Hello World'}, 'lex value still not a ref');
34 is($lh->maketext('Hello World'), 'Bonjour Monde', 'renders correctly second time time');
35 ok(exists $lh->{'_external_lex_cache'}{'Hello World'} && ref $lh->{'_external_lex_cache'}{'Hello World'}, 'still compiled into lex_cache');
36 ok(exists $MyTestLocale::fr::Lexicon{'Hello World'} && !ref $MyTestLocale::fr::Lexicon{'Hello World'}, 'lex value still not a ref');
38 is($lh->maketext('This is not a key'), 'This is not a key', '_AUTO renders correctly first time');
39 ok(exists $lh->{'_external_lex_cache'}{'This is not a key'} && ref $lh->{'_external_lex_cache'}{'This is not a key'}, '_AUTO compiled into lex_cache');
40 ok(!exists $MyTestLocale::fr::Lexicon{'This is not a key'}, '_AUTO lex value not added to lex');