| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Quiq::Test::Class::Method - Testmethode | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | L<Quiq::Object> | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Ein Objekt der Klasse Quiq::Test::Class::Method repräsentiert eine | ||||||||||||||||||||||||||||
| 16 | Testmethode. Das Objekt kapselt Paketnamen, Methodennamen, | ||||||||||||||||||||||||||||
| 17 | Codereferenz, Anzahl der Tests, den Type der Testmethode | ||||||||||||||||||||||||||||
| 18 | und den Gruppen-Regex, sofern vorhanden. | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | package Quiq::Test::Class::Method; | ||||||||||||||||||||||||||||
| 25 | 270 | ▶ | use base qw/Quiq::Object/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 270 | ▶ | use v5.10; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 270 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 270 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 270 | our $VERSION = '1.240'; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | =head1 METHODS | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =head2 Konstruktor | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head3 new() - Instantiiere Testmethodenobjekt | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | $meth = $class->new($pkg,$ref,$type,$n,$group); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head4 Description | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Instantiiere Testmethodenobjekt für Klasse $pkg, Methode $ref | ||||||||||||||||||||||||||||
| 48 | (Codereferenz), Methodentyp $type (Init, Foreach, Startup, Setup, Test, | ||||||||||||||||||||||||||||
| 49 | Teardown, Shutdown), Anzahl Tests $n und Gruppenregex $group. | ||||||||||||||||||||||||||||
| 50 | Liefere eine Referenz auf dieses Objekt zurück. | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1038 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 57 | 1038 | my $class = shift; | |||||||||||||||||||||||||||
| 58 | 1038 | my $pkg = shift; | |||||||||||||||||||||||||||
| 59 | 1038 | my $ref = shift; | |||||||||||||||||||||||||||
| 60 | 1038 | my $type = shift; | |||||||||||||||||||||||||||
| 61 | 1038 | my $n = shift; | |||||||||||||||||||||||||||
| 62 | 1038 | my $group = shift; # nur Setup, Teardown | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1038 | ▶ | $group = qr/$group/ if $group; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1038 | return bless [$pkg,$ref,$type,$n,$group,undef],$class; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head2 Methoden | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | =head3 class() - Liefere Name der getesteten Klasse | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | $class = $meth->class; | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head4 Description | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | Liefere den Namen der getesteten Klasse. | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 1038 | ▶ | sub class { | ||||||||||||||||||||||||||
|
Subroutine
class: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 1038 | return shift->[0]; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =head3 code() - Liefere Codereferenz | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | $ref = $meth->code; | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head4 Description | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | Liefere Codereferenz. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 2076 | ▶ | sub code { | ||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 108 | 2076 | return shift->[1]; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head3 group() - Liefere Gruppen-Regex | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | $regex = $meth->group; | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head4 Description | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Liefere Gruppen-Regex. | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =cut | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 4 | ▶ | sub group { | ||||||||||||||||||||||||||
|
Subroutine
group: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 4 | return shift->[4]; | |||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head3 name() - Liefere Methodennamen | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | $name = $meth->name; | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =head4 Description | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Liefere den Methodennamen. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =cut | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 2831 | ▶ | sub name { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 148 | 2831 | my $self = shift; | |||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 2831 | ▶ | unless ($self->[5]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 1038 | my $pkg = $self->class; | |||||||||||||||||||||||||||
| 152 | 1038 | my $ref = $self->code; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 270 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 155 | 1038 | for my $sym (values %{$pkg.'::'}) | |||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||
| 157 | 12267 | ▶ | if (*{$sym}{'CODE'} && *{$sym}{'CODE'} == $ref) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
*{$sym;}{"CODE"} and *{$sym;}{"CODE"} == $ref
MC/DC100%2/2
*{$sym;}{"CODE"} and *{$sym;}{"CODE"} == $ref
*{$sym;}{"CODE"}
*{$sym;}{"CODE"} == $ref
Truth table100%3/3
A and B
A= *{$sym;}{"CODE"}B= *{$sym;}{"CODE"} == $ref
| |||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||
| 159 | 1038 | $sym =~ /([^:]+)$/; # Paketnamen entfernen | |||||||||||||||||||||||||||
| 160 | 1038 | return $self->[5] = $1; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | $self->throw( | ||||||||||||||||||||||||||||
| 164 | 0 | 'TEST-00001: Test-Subroutine nicht gefunden', | |||||||||||||||||||||||||||
| 165 | Package => $pkg, | ||||||||||||||||||||||||||||
| 166 | Reference => $ref, | ||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 1793 | return $self->[5]; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | =head3 tests() - Liefere Anzahl Tests | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | $n = $meth->tests; | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head4 Description | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | Liefere die Anzahl der Tests in der Testmethode. | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 2065 | ▶ | sub tests { | ||||||||||||||||||||||||||
|
Subroutine
tests: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 2065 | return shift->[3]; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | =head3 type() - Liefere Typ der Testmethode | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =head4 Synopsis | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | $type = $meth->type; | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =head4 Description | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | Liefere den Type der Testmethode. | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | =cut | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 1038 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 210 | 1038 | return shift->[2]; | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =head1 VERSION | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 1.240 | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | Copyright (C) 2026 Frank Seitz | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | This code is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 230 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | =cut | ||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | # ----------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 270 | 1; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | # eof | ||||||||||||||||||||||||||||