File Coverage

blib/lib/Text/Layout/Testing.pm
Criterion Covered Total %
statement 30 37 81.0
branch 4 4 100.0
condition 13 15 86.6
subroutine 8 11 72.7
pod 1 4 25.0
total 56 71 78.8


line stmt bran cond sub pod time code
1             #! perl
2              
3 4     4   851648 use strict;
  4         11  
  4         186  
4 4     4   23 use warnings;
  4         28  
  4         282  
5 4     4   1675 use utf8;
  4         1072  
  4         29  
6 4     4   155 use Carp;
  4         16  
  4         426  
7              
8             package Text::Layout::Testing;
9              
10 4     4   1729 use parent 'Text::Layout';
  4         1397  
  4         24  
11              
12 4     4   324 use Text::Layout::FontConfig;
  4         7  
  4         1621  
13              
14             my $fc = Text::Layout::FontConfig->new( corefonts => 1 );
15              
16             #### API
17             sub new {
18 3     3 1 555135 my ( $pkg, @data ) = @_;
19 3         40 my $self = $pkg->SUPER::new;
20 3         28 $self->set_font_description( $fc->from_string("Times 10") );
21 3         9 $self;
22             }
23              
24             #### API
25             sub render {
26 0     0 0 0 my ( $self ) = @_;
27 0         0 my $res = "Testing 1 2 3";
28 0         0 $res;
29             }
30              
31             #### API
32             sub bbox {
33 0     0 0 0 my ( $self ) = @_;
34 0         0 [ 0, -5, 10, 15 ]; # dummy
35             }
36              
37             #### API
38             sub load_font {
39 0     0 0 0 my ( $self, $description ) = @_;
40 0         0 return $description;
41             }
42              
43             # For testing.
44             sub _debug_text {
45 23     23   60 my $c = $_[0]->{_content};
46 23         50 for my $f ( @$c ) {
47             $f->{font} = $f->{font}->{loader_data} . "(" .
48             join(",", $f->{font}->{family},
49             $f->{font}->{style},
50             $f->{font}->{weight},
51 70   66     368 $f->{font}->{size} // $f->{size}) . ")";
52 70         318 for ( keys %$f ) {
53             $f->{$_} = sprintf("%.3f",$f->{$_})
54 980 100 66     1901 if $_ eq "size" && defined($f->{$_}) && int($f->{$_}) != $f->{$_};
      100        
55             next if defined($f->{$_})
56 980 100 100     3536 && ! ( !$f->{$_} || /col/ && $f->{$_} eq 'black' );
      100        
57 687         1052 delete $f->{$_};
58             }
59             }
60 23         163 return $c;
61             }
62              
63             1;