Skip to content

Commit 27df528

Browse files
committed
Ensure status checks have a value and test. Fixes #39
1 parent 7b76d30 commit 27df528

File tree

5 files changed

+28
-25
lines changed

5 files changed

+28
-25
lines changed

META.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"Gisle Aas <[email protected]>"
55
],
66
"dynamic_config" : 0,
7-
"generated_by" : "Dist::Zilla version 6.007, CPAN::Meta::Converter version 2.150010",
7+
"generated_by" : "Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150010",
88
"license" : [
99
"perl_5"
1010
],
@@ -118,15 +118,16 @@
118118
"Jerome Eteve <[email protected]>",
119119
"john9art <[email protected]>",
120120
"Karen Etheridge <[email protected]>",
121+
"Karen Etheridge <[email protected]>",
121122
"Mark Overmeer <[email protected]>",
122123
"Mark Stosberg <[email protected]>",
123124
"Mark Stosberg <[email protected]>",
124125
"Mark Stosberg <[email protected]>",
125126
"Martin H. Sluka <[email protected]>",
126127
"mickey <[email protected]>",
127128
"Mickey Nasriachi <[email protected]>",
129+
"Mike Schilli <[email protected]>",
128130
"Mike Schilli <[email protected]>",
129-
"mschilli <[email protected]>",
130131
"murphy <[email protected]>",
131132
"Olaf Alders <[email protected]>",
132133
"Olivier Mengu\u00e9 <[email protected]>",
@@ -153,6 +154,6 @@
153154
"Yuri Karaban <[email protected]>",
154155
"Zefram <[email protected]>"
155156
],
156-
"x_serialization_backend" : "Cpanel::JSON::XS version 3.0217"
157+
"x_serialization_backend" : "Cpanel::JSON::XS version 3.0225"
157158
}
158159

Makefile.PL

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.007.
1+
# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008.
22
use strict;
33
use warnings;
44

lib/HTTP/Status.pm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,12 @@ our %EXPORT_TAGS = (
102102

103103
sub status_message ($) { $StatusCode{$_[0]}; }
104104

105-
sub is_info ($) { $_[0] >= 100 && $_[0] < 200; }
106-
sub is_success ($) { $_[0] >= 200 && $_[0] < 300; }
107-
sub is_redirect ($) { $_[0] >= 300 && $_[0] < 400; }
108-
sub is_error ($) { $_[0] >= 400 && $_[0] < 600; }
109-
sub is_client_error ($) { $_[0] >= 400 && $_[0] < 500; }
110-
sub is_server_error ($) { $_[0] >= 500 && $_[0] < 600; }
105+
sub is_info ($) { $_[0] && $_[0] >= 100 && $_[0] < 200; }
106+
sub is_success ($) { $_[0] && $_[0] >= 200 && $_[0] < 300; }
107+
sub is_redirect ($) { $_[0] && $_[0] >= 300 && $_[0] < 400; }
108+
sub is_error ($) { $_[0] && $_[0] >= 400 && $_[0] < 600; }
109+
sub is_client_error ($) { $_[0] && $_[0] >= 400 && $_[0] < 500; }
110+
sub is_server_error ($) { $_[0] && $_[0] >= 500 && $_[0] < 600; }
111111

112112
1;
113113

@@ -267,4 +267,3 @@ the C<:constants> tag instead of relying on this.
267267
=cut
268268
269269
#ABSTRACT: HTTP Status code processing
270-

t/response.t

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ use strict;
55
use warnings;
66

77
use Test::More;
8-
plan tests => 23;
8+
plan tests => 29;
99

1010
use HTTP::Date;
1111
use HTTP::Request;
1212
use HTTP::Response;
1313

14+
# make sure we get no failures from undefined response values
15+
{
16+
my $req = HTTP::Response->new();
17+
is($req->is_success(), undef, 'Empty res: is_success');
18+
is($req->is_info(), undef, 'Empty res: is_info');
19+
is($req->is_redirect(), undef, 'Empty res: is_redirect');
20+
is($req->is_error(), undef, 'Empty res: is_error');
21+
is($req->is_client_error(), undef, 'Empty res: is_client_error');
22+
is($req->is_server_error(), undef, 'Empty res: is_server_error');
23+
}
24+
1425
my $time = time;
1526

1627
my $req = HTTP::Request->new(GET => 'http://www.sn.no');

tidyall.ini

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
[PerlTidy]
22
select = **/*.{pl,pm,t,psgi}
3+
ignore = .build/**/*
4+
ignore = HTTP-Message-*/**/*
5+
ignore = blib/**/*
36
ignore = t/00-*
47
ignore = t/author-*
58
ignore = t/release-*
6-
ignore = blib/**/*
7-
ignore = .build/**/*
8-
ignore = HTTP-Message-*/**/*
9+
ignore = t/zzz-*
10+
ignore = xt/**/*
911
argv = --profile=$ROOT/perltidyrc
1012

11-
;[PerlCritic]
12-
;select = **/*.{pl,pm,t,psgi}
13-
;ignore = t/00-*
14-
;ignore = t/author-*
15-
;ignore = t/release-*
16-
;ignore = blib/**/*
17-
;ignore = .build/**/*
18-
;ignore = HTTP-Message-*/**/*
19-
;argv = --profile $ROOT/perlcriticrc --program-extensions .pl --program-extensions .t --program-extensions .psgi
20-
2113
[SortLines::Naturally]
2214
select = .gitignore
2315

0 commit comments

Comments
 (0)