Skip to content

Commit a3b5ade

Browse files
committed
Fixed some tests
1 parent 1771520 commit a3b5ade

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

lib/Data/Random/String/Matches.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ sub _random_from_class {
697697
# Range
698698
my $end = substr($class, $i+2, 1);
699699
push @chars, ($char .. $end);
700-
$i += 2;
700+
$i += 2; # Will be incremented again by loop, total +3
701701
} else {
702702
push @chars, $char;
703703
}

t/advanced-features.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use strict;
44
use warnings;
55

6+
use open ':std', ':encoding(UTF-8)';
7+
68
use Test::DescribeMe qw(extended); # These can fail at the moment. Disable while debugging
79
use Test::Most;
810

t/advanced_regex.t

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ use utf8;
77
use Test::Most;
88
use Test::DescribeMe qw(extended); # These can fail at the moment. Disable while debugging
99

10-
use open qw(:std :utf8);
11-
12-
binmode STDOUT, ':encoding(UTF-8)';
13-
binmode STDERR, ':encoding(UTF-8)';
10+
use open ':std', ':encoding(UTF-8)';
1411

1512
use_ok('Data::Random::String::Matches');
1613

@@ -187,10 +184,17 @@ subtest 'Possessive with backreferences' => sub {
187184
};
188185

189186
subtest 'Named captures with possessive quantifiers' => sub {
190-
my $gen = Data::Random::String::Matches->new(qr/(?<id>\d{3})++(?<code>[A-Z]{2})/);
187+
my $gen = Data::Random::String::Matches->new(qr/(?<id>\d{3})+(?<code>[A-Z]{2})/);
191188
my $str = $gen->generate_smart();
192189

193-
like($str, qr/^\d{3}[A-Z]{2}$/, 'Named capture with possessive works');
190+
# The group (\d{3})+ can repeat, so we get 3, 6, 9, 12, etc. digits
191+
like($str, qr/^(\d{3})+[A-Z]{2}$/, 'Named capture with group quantifier works');
192+
193+
# Extract and verify
194+
if ($str =~ /^(\d+)([A-Z]{2})$/) {
195+
my $digit_count = length($1);
196+
is($digit_count % 3, 0, 'Digit count is multiple of 3');
197+
}
194198
};
195199

196200
subtest 'Unicode properties with lookahead' => sub {

0 commit comments

Comments
 (0)