RST/Suite.pm untested

filter: Statementstmt 0.0% 0 / 55 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 90 CC 7 SCAR 17.7
CC
7
Cov
0%
cases
12.0
plans
6.0
inputs
6.0
CRAP 5.9
1 package ICANN::RST::Suite;
2 # ABSTRACT: an object representing an RST test suite.
3 use base qw(ICANN::RST::Base);
4 use strict;
5  
6 #
7 # if GraphViz2 is available then we can load ICANN::RST::Graph
8 #
9 eval qq(use ICANN::RST::Graph;) if (eval qq(use GraphViz2 ; 1));
10  
11 sub name { $_[0]->{'Name'} }
12 sub description { ICANN::RST::Text->new($_[0]->{'Description'}) }
13 sub graph { ICANN::RST::Graph->new($_[0]->cases) }
14  
15 sub plans {
16 my $self = shift;
17  
18 my %plans;
19  
20 foreach my $plan ($self->spec->plans) {
21 foreach my $suite ($plan->suites) {
22 $plans{$plan->id} = $plan if ($self->id eq $suite->id && !defined($plans{$plan->id}));
23 }
24 }
25  
26 return sort { $a->order <=> $b->order } values(%plans);
27 }
28  
29 sub cases {
30 my $self = shift;
31  
32 my @cases;
33  
34 if ('ARRAY' eq ref($self->{'Test-Cases'})) {
35 @cases = map { $self->spec->case($_) } @{$self->{'Test-Cases'}};
36  
37 } elsif (defined($self->{'Test-Cases'})) {
38 @cases = grep { $_->id =~ /$self->{'Test-Cases'}/ } $self->spec->cases;
39  
40 }
41  
42 return sort { $a->id cmp $b->id } @cases;
43 }
44  
45 sub inputs {
46 my $self = shift;
47  
48 my %inputs;
49  
50 foreach my $id (@{$self->{'Input-Parameters'}}) {
51 $inputs{$id} = $self->spec->input($id);
52 }
53  
54 foreach my $case ($self->cases) {
55 foreach my $input ($case->inputs) {
56 $inputs{$input->id} = $input unless (defined($inputs{$input->id}));
57 }
58 }
59  
60 return sort { $a->id cmp $b->id } values(%inputs);
61 }
62  
63 sub resources {
64 my $self = shift;
65  
66 my %resources;
67 foreach my $id (@{$self->{'Resources'}}) {
68 $resources{$id} = $self->spec->resource($id);
69 }
70  
71 foreach my $case ($self->cases) {
72 foreach my $resource ($case->resources) {
73 $resources{$resource->id} = $resource unless (defined($resources{$resource->id}));
74 }
75 }
76  
77 return sort { $a->id cmp $b->id } values(%resources);
78 }
79  
80 sub errors {
81 my $self = shift;
82  
83 my %errors;
84 foreach my $case ($self->cases) {
85 foreach my $error ($case->errors) {
86 $errors{$error->id} = $error unless (defined($errors{$error->id}));
87 }
88 }
89  
90 return sort { $a->id cmp $b->id } values(%errors);
91 }
92  
93 1;
94  
95 __END__
96  
97 =pod
98  
99 =encoding UTF-8
100  
101 =head1 NAME
102  
103 ICANN::RST::Suite - an object representing an RST test suite.
104  
105 =head1 VERSION
106  
107 version 0.03
108  
109 =head1 DESCRIPTION
110  
111 This class inherits from L<ICANN::RST::Base> (so it has the C<id()>,
112 C<order()> and C<spec()> methods).
113  
114 =head1 METHODS
115  
116 =head2 name()
117  
118 The name of the suite.
119  
120 =head2 description()
121  
122 A L<ICANN::RST::Text> object containing the long textual description of the
123 suite.
124  
125 =head2 cases()
126  
127 A list of L<ICANN::RST::Case> objects used by this suite.
128  
129 =head2 inputs()
130  
131 A list of L<ICANN::RST::Inputs> objects used by the test cases used by this
132 suite.
133  
134 =head2 resources()
135  
136 A list of L<ICANN::RST::Resources> objects relevant to this suite.
137  
138 =head2 errors()
139  
140 A list of L<ICANN::RST::Error> objects which may be produced by this suite.
141  
142 =head2 graph()
143  
144 Returns a L<GraphViz2> object visualising the sequence of tests for this suite.
145  
146 =head1 AUTHOR
147  
148 Gavin Brown <gavin.brown@icann.org>
149  
150 =head1 COPYRIGHT AND LICENSE
151  
152 This software is copyright (c) 2025 by Internet Corporation for Assigned Names and Number (ICANN).
153  
154 This is free software; you can redistribute it and/or modify it under
155 the same terms as the Perl 5 programming language system itself.
156  
157 =cut