line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Tools::Expressive; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
140650
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
28
|
|
5
|
2
|
|
|
2
|
|
5
|
use warnings; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
75
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Test2::Tools::Expressive -- Expressive tools for Perl's Test2 framework |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.01_01 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.01_01'; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
732
|
use parent 'Exporter'; |
|
2
|
|
|
|
|
417
|
|
|
2
|
|
|
|
|
7
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
22
|
|
|
|
|
|
|
is_undef |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
115
|
use Test2::API qw( context ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
230
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Test2::Tools::Expressive; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $user = get_user_object( $bogus_id ); |
34
|
|
|
|
|
|
|
is_undef( $user, 'Should not be able to find a user with a bogus ID' ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 WHY TEST::EXPRESSIVE? |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Test2::Tools::Expressive is designed to make your code more readable, |
39
|
|
|
|
|
|
|
based on the idea that reading English is easier and less prone to |
40
|
|
|
|
|
|
|
misinterpretation than reading Perl, and less prone to error by reducing |
41
|
|
|
|
|
|
|
common cut & paste tasks. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 EXPORTS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
All functions in this module are exported by default. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SUBROUTINES |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head2 is_undef( $got [, $name ] ) |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Verifies that C<$got> is undefined. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
You must pass at least one argument. Otherwise, calling C |
55
|
|
|
|
|
|
|
with no parameters would pass. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub is_undef { |
60
|
15
|
|
|
15
|
1
|
109406
|
my $nargs = scalar @_; |
61
|
|
|
|
|
|
|
|
62
|
15
|
|
|
|
|
16
|
my $got = shift; |
63
|
15
|
|
|
|
|
12
|
my $name = shift; |
64
|
|
|
|
|
|
|
|
65
|
15
|
|
|
|
|
11
|
my $ok; |
66
|
15
|
|
|
|
|
21
|
my $ctx = context(); |
67
|
|
|
|
|
|
|
|
68
|
15
|
100
|
|
|
|
694
|
if ( $nargs == 0 ) { |
69
|
1
|
|
|
|
|
4
|
$ok = $ctx->ok( 0, $name ); |
70
|
1
|
|
|
|
|
107
|
$ctx->diag( 'Must pass a value to is_undef' ); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
14
|
|
|
|
|
36
|
$ok = $ctx->ok( !defined $got, $name ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
15
|
|
|
|
|
1112
|
$ctx->release; |
77
|
|
|
|
|
|
|
|
78
|
15
|
|
|
|
|
216
|
return $ok; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 AUTHOR |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Andy Lester, C<< >> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 BUGS |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
88
|
|
|
|
|
|
|
L. |
89
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress |
90
|
|
|
|
|
|
|
on your bug as I make changes. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SUPPORT |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
perldoc Test2::Tools::Expressive |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
You can also look for information at: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item * GitHub project page |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
L |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * CPAN Ratings |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * Search CPAN |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright 2016 Andy Lester. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
129
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
130
|
|
|
|
|
|
|
copy of the full license at: |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
135
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
136
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
137
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
140
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
141
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
144
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
147
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
148
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
149
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
150
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
151
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
152
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
153
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
156
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
157
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
158
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
159
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
160
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
161
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
162
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; # End of Test2::Tools::Expressive |