Skip to content

Commit d0d56ab

Browse files
manwaroalders
authored andcommitted
Making use of Test::Warnings for testing warn message.
1 parent 4d056b9 commit d0d56ab

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

t/find_input.t

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
use strict;
44
use warnings;
5-
use Test::More tests => 7;
6-
use HTML::Form;
5+
use Test::More;
6+
use HTML::Form ();
7+
use Test::Warnings qw(warning);
78

89
my $html = '<html><body><form></form></body></html>';
910

@@ -29,13 +30,13 @@ ok(
2930
like( $@, qr/Invalid index a/, 'exception text' );
3031

3132
{
32-
my @warnings;
33-
local $SIG{__WARN__} = sub { push @warnings, shift };
34-
my @inputs = $form->find_input( 'submit', 'input', 1 );
35-
is( scalar @warnings, 1, 'warns' );
36-
is(
37-
$warnings[0],
38-
"find_input called in list context with index specified\n",
33+
like(
34+
warning {
35+
my @inputs = $form->find_input( 'submit', 'input', 1 );
36+
},
37+
qr/^find_input called in list context with index specified/,
3938
'warning text'
4039
);
4140
}
41+
42+
done_testing;

0 commit comments

Comments
 (0)