line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Proto::Role::Tagged; |
2
|
14
|
|
|
14
|
|
146934
|
use 5.008; |
|
14
|
|
|
|
|
58
|
|
|
14
|
|
|
|
|
594
|
|
3
|
14
|
|
|
14
|
|
84
|
use strict; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
478
|
|
4
|
14
|
|
|
14
|
|
87
|
use warnings; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
1068
|
|
5
|
14
|
|
|
14
|
|
89
|
use Moo::Role; |
|
14
|
|
|
|
|
26
|
|
|
14
|
|
|
|
|
113
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Test::Proto::Role::Tags - Role containing methods for tagging cases and prototypes |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This class is not for public consumption, only its methods are. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
It is a role used to provide for accessing 'tags', which are flags associated with a test case (L) or prototype (L) to give clues to the runner or formatter to indicate how to deal with the object. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 METHODS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head3 tags |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$object->tags; # returns ['tag1', 'tag2'], etc. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Returns the associated tags. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has tags => is => 'rw', |
29
|
|
|
|
|
|
|
default => sub { [] }; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head3 add_tag |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$object->add_tag('author_testing'); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Adds the tag to the object, and returns the object. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub add_tag { |
40
|
8
|
|
|
8
|
1
|
18
|
my ( $self, $tag ) = @_; |
41
|
8
|
|
|
|
|
20
|
my $tags = $self->tags; |
42
|
8
|
100
|
|
|
|
32
|
push @$tags, $tag unless grep { $_ eq $tag } @$tags; |
|
4
|
|
|
|
|
22
|
|
43
|
8
|
|
|
|
|
35
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head3 has_tag |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$object->has_tag('author_testing'); # returns 0 or 1 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Determines if the object has this tag. Exact matches only. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub has_tag { |
55
|
16
|
|
|
16
|
1
|
11624
|
my ( $self, $tag ) = @_; |
56
|
16
|
|
|
|
|
22
|
foreach my $t ( @{ $self->tags } ) { |
|
16
|
|
|
|
|
47
|
|
57
|
8
|
100
|
|
|
|
44
|
return 1 if $t eq $tag; |
58
|
|
|
|
|
|
|
} |
59
|
12
|
|
|
|
|
70
|
return 0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head3 remove_tag |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$object->remove_tag('author_testing'); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Removes the tag and returns the object. Does nothing if the tag was not present to begin with. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub remove_tag { |
71
|
8
|
|
|
8
|
1
|
15
|
my ( $self, $tag ) = @_; |
72
|
8
|
|
|
|
|
18
|
my $tags = $self->tags; |
73
|
8
|
100
|
|
|
|
26
|
return $self unless @$tags; |
74
|
6
|
|
|
|
|
10
|
for my $i ( 0 .. $#{$tags} ) { |
|
6
|
|
|
|
|
17
|
|
75
|
8
|
100
|
|
|
|
25
|
if ( $tag eq $tags->[$i] ) { |
76
|
4
|
|
|
|
|
13
|
delete $tags->[$i]; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
6
|
|
|
|
|
52
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 OTHER INFORMATION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
For author, version, bug reports, support, etc, please see L. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |