File: 11ppiexp.t

package info (click to toggle)
liblog-report-lexicon-perl 1.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 440 kB
  • sloc: perl: 2,673; makefile: 9
file content (66 lines) | stat: -rw-r--r-- 1,541 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env perl
# Try Extract PPI

use warnings;
use strict;

use File::Temp   qw/tempdir/;
use Test::More;

use Log::Report 'my-domain';
use_ok 'Log::Report::Translator::POT';

BEGIN
{   eval "require PPI";
    plan skip_all => 'PPI not installed'
        if $@;

    plan tests => 11;
    use_ok('Log::Report::Extract::PerlPPI');
}

my $lexicon    = tempdir CLEANUP => 1;
#warn "Lexicon at $lexicon";

my $rules =
  { gender => [ 'male', 'female' ]
  , formal => [ 'informal', 'formal' ]
  };

my $domain = textdomain 'my-domain', context_rules => $rules;
isa_ok $domain, 'Log::Report::Domain';

### Create tables

my $ppi = Log::Report::Extract::PerlPPI->new(lexicon => $lexicon);
ok defined $ppi, 'created parser';
isa_ok $ppi, 'Log::Report::Extract::PerlPPI';

$ppi->process( __FILE__ );   # yes, this file!
$ppi->write;

#### 

my $old = textdomain 'my-domain', 'DELETE';   # restart administration
isa_ok $old, 'Log::Report::Domain', 'caught deleted';

my $translator = Log::Report::Translator::POT->new(lexicon => $lexicon);

my $new = textdomain 'my-domain'
  , context_rules => $rules
  , translator    => $translator;

isa_ok $new, 'Log::Report::Domain', 'recreated';
cmp_ok $old, '!=', $new, 'new is really new';

$new->setContext('gender=male,formal=informal');

my $a1 = __x"{name<gender} forgot his key", name => 'Mark';
is $a1, 'Mark forgot his key', 'Mark';

my $a2 = __xn"Dear Sir,{<gender<formal}", "Dear Sirs,", 3;
is $a2, 'Dear Sirs,';

my $a3 = __x"no context {where}", where => 'here';
is $a3, 'no context here';