1use Test::More tests => 11; 2 3BEGIN { 4 use_ok('Locale::Maketext'); 5}; 6 7package MyTestLocale; 8 9@MyTestLocale::ISA = qw(Locale::Maketext); 10%MyTestLocale::Lexicon = (); 11%MyTestLocale::Lexicon = (); # to avoid warnings 12 13package MyTestLocale::fr; 14 15@MyTestLocale::fr::ISA = qw(MyTestLocale); 16 17%MyTestLocale::fr::Lexicon = ( 18 '_AUTO' => 1, 19 'Hello World' => 'Bonjour Monde', 20); 21 22package main; 23 24my $lh = MyTestLocale->get_handle('fr'); 25$lh->{'use_external_lex_cache'} = 1; 26ok(exists $MyTestLocale::fr::Lexicon{'Hello World'} && !ref $MyTestLocale::fr::Lexicon{'Hello World'}, 'lex value not a ref'); 27 28is($lh->maketext('Hello World'), 'Bonjour Monde', 'renders correctly first time'); 29ok(exists $lh->{'_external_lex_cache'}{'Hello World'} && ref $lh->{'_external_lex_cache'}{'Hello World'}, 'compiled into lex_cache'); 30ok(exists $MyTestLocale::fr::Lexicon{'Hello World'} && !ref $MyTestLocale::fr::Lexicon{'Hello World'}, 'lex value still not a ref'); 31 32is($lh->maketext('Hello World'), 'Bonjour Monde', 'renders correctly second time time'); 33ok(exists $lh->{'_external_lex_cache'}{'Hello World'} && ref $lh->{'_external_lex_cache'}{'Hello World'}, 'still compiled into lex_cache'); 34ok(exists $MyTestLocale::fr::Lexicon{'Hello World'} && !ref $MyTestLocale::fr::Lexicon{'Hello World'}, 'lex value still not a ref'); 35 36is($lh->maketext('This is not a key'), 'This is not a key', '_AUTO renders correctly first time'); 37ok(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'); 38ok(!exists $MyTestLocale::fr::Lexicon{'This is not a key'}, '_AUTO lex value not added to lex'); 39