Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric ranges #477

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clicktest: vary_from_index: abbreviate single-digit regex ranges
E.g. '[3-3]' can be replaced by just '3'. Making this change to make
generated regexes a bit more readable.

Reviewed-by: Yoann Desmouceaux <[email protected]>
  • Loading branch information
Patrick Verkaik committed Jan 21, 2021
commit 391478cbfcbf0f54455858e304c6f88dcdd4455f
7 changes: 4 additions & 3 deletions test/clicktest
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ sub vary_from_index($$$;$) {

my $digit = substr($num, $start_index, 1);
die "digit > index_digit_max" if $digit > $index_digit_max;
my ($middle_re, $middle_max) = ("[$digit-$index_digit_max]", $index_digit_max);
my $middle_re = ($digit == $index_digit_max) ? $digit : "[$digit-$index_digit_max]";
my $middle_max = $index_digit_max;

my $suffix_len = length($num) - length($start) - 1;
my ($end_re, $end_max) = ('\d' x $suffix_len, 9 x $suffix_len);
Expand Down Expand Up @@ -690,8 +691,8 @@ sub test_expand_int_ranges() {

my @cases = (
['', ''],
['{{~1-2}}', '([1-1]|2)'],
['before{{~1-2}}{{xxx}}{{~3-4}}after', 'before([1-1]|2){{xxx}}([3-3]|4)after'],
['{{~1-2}}', '(1|2)'],
['before{{~1-2}}{{xxx}}{{~3-4}}after', 'before(1|2){{xxx}}(3|4)after'],
);

for my $c (@cases) {
Expand Down