| 1 | package Test::Run::Obj::FailedObj; | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | Test::Run::Obj::FailedObj - an object representing a failure. | ||||||||||
| 6 | |||||||||||
| 7 | =head1 DESCRIPTION | ||||||||||
| 8 | |||||||||||
| 9 | Inherits from Test::Run::Base::Struct. | ||||||||||
| 10 | |||||||||||
| 11 | =head1 METHODS | ||||||||||
| 12 | |||||||||||
| 13 | =cut | ||||||||||
| 14 | |||||||||||
| 15 | 5 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 5 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 5 | ▶ | use vars qw(@fields); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | |||||||||||
| 20 | 5 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 5 | ▶ | use Test::Run::Obj::IntOrUnknown; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 5 | extends('Test::Run::Base::Struct'); | |||||||||
| 25 | |||||||||||
| 26 | 5 | has 'canon' => (is => "rw", isa => "Str"); | |||||||||
| 27 | 5 | has 'canon_strings' => (is => "rw", isa => "ArrayRef"); | |||||||||
| 28 | 5 | has 'estat' => (is => "rw", isa => "Str"); | |||||||||
| 29 | 5 | has 'failed' => (is => 'rw', isa => 'Test::Run::Obj::IntOrUnknown', | |||||||||
| 30 | handles => | ||||||||||
| 31 | { | ||||||||||
| 32 | 'failed_str' => 'get_string_val', | ||||||||||
| 33 | }, | ||||||||||
| 34 | ); | ||||||||||
| 35 | 5 | has 'max' => (is => 'rw', isa => 'Test::Run::Obj::IntOrUnknown', | |||||||||
| 36 | handles => | ||||||||||
| 37 | { | ||||||||||
| 38 | 'max_str' => 'get_string_val', | ||||||||||
| 39 | }, | ||||||||||
| 40 | ); | ||||||||||
| 41 | 5 | has 'list_len' => (is => "rw", isa => "Num"); | |||||||||
| 42 | 5 | has 'name' => (is => "rw", isa => "Str"); | |||||||||
| 43 | 5 | has 'percent' => (is => "rw", isa => "Maybe[Str]"); | |||||||||
| 44 | 5 | has 'wstat' => (is => "rw", isa => "Str"); | |||||||||
| 45 | |||||||||||
| 46 | =head2 $self->_defined_percent() | ||||||||||
| 47 | |||||||||||
| 48 | Returns a defined percentage. It returns the percentage or 0 if it is | ||||||||||
| 49 | undefined. | ||||||||||
| 50 | |||||||||||
| 51 | =cut | ||||||||||
| 52 | |||||||||||
| 53 | sub _defined_percent | ||||||||||
| 54 | 7 | ▶ | { | ||||||||
|
Subroutine
_defined_percent: called CC=2 SCAR=6.9
| |||||||||||
| 55 | 7 | my $self = shift; | |||||||||
| 56 | |||||||||||
| 57 | 7 | ▶ | return defined($self->percent()) ? $self->percent() : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | sub _do_canon_concat | ||||||||||
| 61 | 4 | ▶ | { | ||||||||
|
Subroutine
_do_canon_concat: called CC=2 SCAR=7.2
| |||||||||||
| 62 | 4 | my ($self, $ret, $canon) = @_; | |||||||||
| 63 | |||||||||||
| 64 | 4 | my $first = shift(@$canon); | |||||||||
| 65 | |||||||||||
| 66 | 4 | my $new_last_ret = "$ret->[-1] $first"; | |||||||||
| 67 | |||||||||||
| 68 | 4 | ▶ | if (length($new_last_ret) < $self->list_len()) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | { | ||||||||||
| 70 | 4 | $ret->[-1] = $new_last_ret; | |||||||||
| 71 | } | ||||||||||
| 72 | else | ||||||||||
| 73 | { | ||||||||||
| 74 | 0 | push @$ret, $first; | |||||||||
| 75 | } | ||||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | sub _calc_stringification | ||||||||||
| 79 | 7 | ▶ | { | ||||||||
|
Subroutine
_calc_stringification: called CC=2 SCAR=6.9
| |||||||||||
| 80 | 7 | my ($self, $canon) = @_; | |||||||||
| 81 | |||||||||||
| 82 | 7 | my @ret = shift(@$canon); | |||||||||
| 83 | |||||||||||
| 84 | 7 | ▶ | while (@$canon) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | { | ||||||||||
| 86 | 4 | $self->_do_canon_concat(\@ret, $canon); | |||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 7 | return \@ret; | |||||||||
| 90 | } | ||||||||||
| 91 | |||||||||||
| 92 | sub _assign_canon_strings | ||||||||||
| 93 | 7 | ▶ | { | ||||||||
|
Subroutine
_assign_canon_strings: called CC=1 SCAR=0.0
| |||||||||||
| 94 | 7 | my $self = shift; | |||||||||
| 95 | |||||||||||
| 96 | 7 | my $args = shift; | |||||||||
| 97 | |||||||||||
| 98 | 7 | $self->list_len($args->{main}->list_len()); | |||||||||
| 99 | |||||||||||
| 100 | 7 | $self->canon_strings( | |||||||||
| 101 | $self->_calc_stringification( | ||||||||||
| 102 | [ split /\s+/, $self->canon() ], | ||||||||||
| 103 | ) | ||||||||||
| 104 | ); | ||||||||||
| 105 | } | ||||||||||
| 106 | |||||||||||
| 107 | =head2 $self->first_canon_string() | ||||||||||
| 108 | |||||||||||
| 109 | The first of the canon_strings(). (With index 0). | ||||||||||
| 110 | |||||||||||
| 111 | =cut | ||||||||||
| 112 | |||||||||||
| 113 | sub first_canon_string | ||||||||||
| 114 | 7 | ▶ | { | ||||||||
|
Subroutine
first_canon_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 115 | 7 | my $self = shift; | |||||||||
| 116 | |||||||||||
| 117 | 7 | return $self->canon_strings()->[0]; | |||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | =head2 $self->rest_of_canons() | ||||||||||
| 121 | |||||||||||
| 122 | An array reference containing all the canons except the 0th. | ||||||||||
| 123 | |||||||||||
| 124 | =cut | ||||||||||
| 125 | |||||||||||
| 126 | sub rest_of_canons | ||||||||||
| 127 | 7 | ▶ | { | ||||||||
|
Subroutine
rest_of_canons: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 128 | 7 | my $self = shift; | |||||||||
| 129 | |||||||||||
| 130 | 7 | my $canons = $self->canon_strings(); | |||||||||
| 131 | |||||||||||
| 132 | 7 | return [ @{$canons}[ 1 .. ($#$canons-1) ] ]; | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | =head2 $self->max_str() | ||||||||||
| 136 | |||||||||||
| 137 | A string representation of max. | ||||||||||
| 138 | |||||||||||
| 139 | =head2 $self->failed_str() | ||||||||||
| 140 | |||||||||||
| 141 | A string representation of failed. | ||||||||||
| 142 | |||||||||||
| 143 | =cut | ||||||||||
| 144 | |||||||||||
| 145 | 5 | 1; | |||||||||
| 146 | |||||||||||
| 147 | __END__ | ||||||||||