Skip to content

Commit e7c425d

Browse files
committed
[i] test unsuccessful matching
Took 5 minutes
1 parent 02b5560 commit e7c425d

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

t/02_matches.t

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use strict;
22
use warnings qw/FATAL/;
33
use utf8;
44

5-
use Test::Simple tests => 8;
5+
use Test::Simple tests => 9;
66
use Regex::Object;
77

88
$|=1;
@@ -118,6 +118,10 @@ ok($result eq $expected,
118118
## TEST 8
119119
# Test global matching with scoped regex with modifiers: captures_all
120120

121+
$re = Regex::Object->new(
122+
regex => qr/([A-Z]+?) ([A-Z]+)/i,
123+
);
124+
121125
$expected = 'John Doe Eric Lide Hans Zimmermann';
122126
$result = join "\040", map { join "\040", @$_ } @{ $re->match_all($expected)->captures_all };
123127

@@ -127,3 +131,15 @@ ok($result eq $expected,
127131
$expected,
128132
)
129133
);
134+
135+
## TEST 9
136+
# Test unsuccessful matching
137+
138+
$re = Regex::Object->new(regex => qr/\d+/);
139+
$result = $re->match('foo')->success;
140+
141+
ok(!$result,
142+
sprintf('Returns wrong value: %s, expected: undef',
143+
$result,
144+
)
145+
);

0 commit comments

Comments
 (0)