| 1 | package FindApp::Utils::Assert; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use v5.10; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 6 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | 6 | ▶ | use FindApp::Utils::Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | |||||||||||||||
| 9 | ################################################################# | ||||||||||||||
| 10 | |||||||||||||||
| 11 | sub all_args_defined ; | ||||||||||||||
| 12 | sub bad_args ; | ||||||||||||||
| 13 | sub good_args ; | ||||||||||||||
| 14 | sub panic ; | ||||||||||||||
| 15 | sub subcroak ; | ||||||||||||||
| 16 | sub subcroak_N ; | ||||||||||||||
| 17 | sub validate_args ; | ||||||||||||||
| 18 | |||||||||||||||
| 19 | ################################################################# | ||||||||||||||
| 20 | |||||||||||||||
| 21 | 6 | ▶ | use Exporter qw(import); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 22 | 6 | our $VERSION = v1.0; | |||||||||||||
| 23 | 6 | our @EXPORT_OK = qw( | |||||||||||||
| 24 | all_args_defined | ||||||||||||||
| 25 | bad_args | ||||||||||||||
| 26 | good_args | ||||||||||||||
| 27 | panic | ||||||||||||||
| 28 | subcroak | ||||||||||||||
| 29 | subcroak_N | ||||||||||||||
| 30 | ); | ||||||||||||||
| 31 | 6 | our %EXPORT_TAGS = ( | |||||||||||||
| 32 | all => \@EXPORT_OK, | ||||||||||||||
| 33 | ); | ||||||||||||||
| 34 | |||||||||||||||
| 35 | ################################################################# | ||||||||||||||
| 36 | |||||||||||||||
| 37 | 0 | ▶ | sub subcroak { | ||||||||||||
|
Subroutine
subcroak: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 38 | 0 | ▶ | my($package, $filename, $line, $sub) = caller(1); | ||||||||||||
|
Subroutine
subcroak: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 39 | 0 | my $subname = $sub; | |||||||||||||
| 40 | 0 | my $proto = prototype($sub); | |||||||||||||
| 41 | 0 | ▶ | $subname .= "($proto)" if defined $proto; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 42 | |||||||||||||||
| 43 | 0 | croak "$subname: @_"; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 0 | ▶ | sub subcroak_N { | ||||||||||||
|
Subroutine
subcroak_N: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 47 | 0 | ▶ | my $frames = shift; | ||||||||||||
|
Subroutine
subcroak_N: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 48 | 0 | my($package, $filename, $line, $sub) = caller($frames); | |||||||||||||
| 49 | 0 | croak "$sub(): @_"; | |||||||||||||
| 50 | } | ||||||||||||||
| 51 | |||||||||||||||
| 52 | |||||||||||||||
| 53 | 0 | ▶ | sub panic { | ||||||||||||
|
Subroutine
panic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 54 | 0 | ▶ | confess "panic: @_"; | ||||||||||||
|
Subroutine
panic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 2432 | ▶ | sub validate_args { | ||||||||||||
|
Subroutine
validate_args: called CC=3 SCAR=20.6
Pod
documented
| |||||||||||||||
| 58 | 0 | ▶ | my($good_condition) = @_; | ||||||||||||
|
Subroutine
validate_args: not called CC=3 SCAR=20.6
Pod
documented
| |||||||||||||||
| 59 | 0 | ▶ | return if $good_condition; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 60 | 0 | my($package, $file, $line, $sub) = caller(2); | |||||||||||||
| 61 | 0 | ▶ | panic "invalid arguments given to $sub" unless $good_condition; | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 62 | } | ||||||||||||||
| 63 | |||||||||||||||
| 64 | 815 | ▶ | sub bad_args { | ||||||||||||
|
Subroutine
bad_args: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||
| 65 | 0 | ▶ | my($condition) = @_; | ||||||||||||
|
Subroutine
bad_args: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||
| 66 | 0 | validate_args !$condition; | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | |||||||||||||||
| 69 | 1617 | ▶ | sub good_args { | ||||||||||||
|
Subroutine
good_args: called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||
| 70 | 0 | ▶ | &validate_args; | ||||||||||||
|
Subroutine
good_args: not called CC=1 SCAR=1.2
Pod
documented
| |||||||||||||||
| 71 | } | ||||||||||||||
| 72 | |||||||||||||||
| 73 | 0 | ▶ | sub all_args_defined { | ||||||||||||
|
Subroutine
all_args_defined: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 74 | 0 | ▶ | unless (@_ == grep {defined} @_) { | ||||||||||||
|
Subroutine
all_args_defined: not called CC=2 SCAR=17.9
Pod
documented
Branch: 2 branches
| |||||||||||||||
| 75 | 0 | subcroak_N(2, "undefined arguments forbidden"); | |||||||||||||
| 76 | } | ||||||||||||||
| 77 | } | ||||||||||||||
| 78 | |||||||||||||||
| 79 | |||||||||||||||
| 80 | 6 | 1; | |||||||||||||
| 81 | |||||||||||||||
| 82 | =encoding utf8 | ||||||||||||||
| 83 | |||||||||||||||
| 84 | =head1 NAME | ||||||||||||||
| 85 | |||||||||||||||
| 86 | FindApp::Utils::Assert - FIXME | ||||||||||||||
| 87 | |||||||||||||||
| 88 | =head1 SYNOPSIS | ||||||||||||||
| 89 | |||||||||||||||
| 90 | use FindApp::Utils::Assert; | ||||||||||||||
| 91 | |||||||||||||||
| 92 | =head1 DESCRIPTION | ||||||||||||||
| 93 | |||||||||||||||
| 94 | =head2 Public Methods | ||||||||||||||
| 95 | |||||||||||||||
| 96 | =over | ||||||||||||||
| 97 | |||||||||||||||
| 98 | =item FIXME | ||||||||||||||
| 99 | |||||||||||||||
| 100 | =back | ||||||||||||||
| 101 | |||||||||||||||
| 102 | =head2 Exports | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =over | ||||||||||||||
| 105 | |||||||||||||||
| 106 | =item all_args_defined | ||||||||||||||
| 107 | |||||||||||||||
| 108 | =item bad_args | ||||||||||||||
| 109 | |||||||||||||||
| 110 | =item good_args | ||||||||||||||
| 111 | |||||||||||||||
| 112 | =item panic | ||||||||||||||
| 113 | |||||||||||||||
| 114 | =item subcroak | ||||||||||||||
| 115 | |||||||||||||||
| 116 | =item subcroak_N | ||||||||||||||
| 117 | |||||||||||||||
| 118 | =item validate_args | ||||||||||||||
| 119 | |||||||||||||||
| 120 | =item FIXME | ||||||||||||||
| 121 | |||||||||||||||
| 122 | =back | ||||||||||||||
| 123 | |||||||||||||||
| 124 | =head1 EXAMPLES | ||||||||||||||
| 125 | |||||||||||||||
| 126 | =head1 ENVIRONMENT | ||||||||||||||
| 127 | |||||||||||||||
| 128 | =head1 SEE ALSO | ||||||||||||||
| 129 | |||||||||||||||
| 130 | =over | ||||||||||||||
| 131 | |||||||||||||||
| 132 | =item L<FindApp> | ||||||||||||||
| 133 | |||||||||||||||
| 134 | =back | ||||||||||||||
| 135 | |||||||||||||||
| 136 | =head1 CAVEATS AND PROVISOS | ||||||||||||||
| 137 | |||||||||||||||
| 138 | =head1 BUGS AND LIMITATIONS | ||||||||||||||
| 139 | |||||||||||||||
| 140 | =head1 HISTORY | ||||||||||||||
| 141 | |||||||||||||||
| 142 | =head1 AUTHOR | ||||||||||||||
| 143 | |||||||||||||||
| 144 | Tom Christiansen << <tchrist@perl.com> >> | ||||||||||||||
| 145 | |||||||||||||||
| 146 | =head1 LICENCE AND COPYRIGHT | ||||||||||||||
| 147 | |||||||||||||||
| 148 | Copyright (c) 2016, Tom Christiansen C<< <tchrist@perl.com> >>. | ||||||||||||||
| 149 | All Rights Reserved. | ||||||||||||||
| 150 | |||||||||||||||
| 151 | This module is free software; you can redistribute it and/or | ||||||||||||||
| 152 | modify it under the same terms as Perl itself. See L<perlartistic>. | ||||||||||||||
| 153 | |||||||||||||||
| 154 | =cut | ||||||||||||||
| 155 | |||||||||||||||