Skip to content

Commit aa5563f

Browse files
committed
Test some more edge cases
1 parent b757fd7 commit aa5563f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/regexp_parser/scanner/scanner.rl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
group_options = '?' . ( [^!#'():<=>~]+ . ':'? ) ?;
8080

8181
group_name_id_ab = ([^!=0-9\->] | utf8_multibyte) . ([^>] | utf8_multibyte)*;
82-
group_name_id_sq = ([^0-9\-'] | utf8_multibyte) . ([^'] | utf8_multibyte)*;
82+
group_name_id_sq = ([^0-9\-'] | utf8_multibyte) . ([^'] | utf8_multibyte)*;
8383
group_number = '-'? . [0-9]+;
8484
group_level = [+\-] . [0-9]+;
8585

spec/scanner/groups_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Named groups
99
# Names that start with a hyphen or digit (ascii or other) are invalid.
1010
# ")" is only allowed as first char of the name.
11-
# "!" is allowed anywhere, but ?<!...> is treated as a lookbehind by Ruby.
11+
# "!" and "=" are allowed anywhere, but (?<!…>…) and (?<=…>…) are treated as lookbehinds by Ruby.
1212
include_examples 'scan', '(?<name>abc)', 0 => [:group, :named_ab, '(?<name>', 0, 8]
1313
include_examples 'scan', "(?'name'abc)", 0 => [:group, :named_sq, "(?'name'", 0, 8]
1414
include_examples 'scan', '(?<name_1>abc)', 0 => [:group, :named_ab, '(?<name_1>', 0,10]
@@ -17,6 +17,10 @@
1717
include_examples 'scan', "(?'name-1'abc)", 0 => [:group, :named_sq, "(?'name-1'", 0,10]
1818
include_examples 'scan', "(?<name'1>abc)", 0 => [:group, :named_ab, "(?<name'1>", 0,10]
1919
include_examples 'scan', "(?'name>1'abc)", 0 => [:group, :named_sq, "(?'name>1'", 0,10]
20+
include_examples 'scan', "(?<n!me1'>abc)", 0 => [:group, :named_ab, "(?<n!me1'>", 0,10]
21+
include_examples 'scan', "(?'!ame1>'abc)", 0 => [:group, :named_sq, "(?'!ame1>'", 0,10]
22+
include_examples 'scan', "(?<n=me1'>abc)", 0 => [:group, :named_ab, "(?<n=me1'>", 0,10]
23+
include_examples 'scan', "(?'=ame1>'abc)", 0 => [:group, :named_sq, "(?'=ame1>'", 0,10]
2024
include_examples 'scan', '(?<üüuuüü>abc)', 0 => [:group, :named_ab, '(?<üüuuüü>', 0,10]
2125
include_examples 'scan', "(?'üüuuüü'abc)", 0 => [:group, :named_sq, "(?'üüuuüü'", 0,10]
2226
include_examples 'scan', "(?<😋1234😋>abc)", 0 => [:group, :named_ab, "(?<😋1234😋>", 0,10]
@@ -38,10 +42,10 @@
3842
include_examples 'scan', '(?=abc)', 0 => [:assertion, :lookahead, '(?=', 0, 3]
3943
include_examples 'scan', '(?!abc)', 0 => [:assertion, :nlookahead, '(?!', 0, 3]
4044
include_examples 'scan', '(?<=abc)', 0 => [:assertion, :lookbehind, '(?<=', 0, 4]
45+
include_examples 'scan', '(?<=x>)y', 0 => [:assertion, :lookbehind, '(?<=', 0, 4]
4146
include_examples 'scan', '(?<!abc)', 0 => [:assertion, :nlookbehind, '(?<!', 0, 4]
4247
include_examples 'scan', '(?<!x)y>', 0 => [:assertion, :nlookbehind, '(?<!', 0, 4]
4348
include_examples 'scan', '(?<!x>)y', 0 => [:assertion, :nlookbehind, '(?<!', 0, 4]
44-
include_examples 'scan', '(?<=x>)y', 0 => [:assertion, :lookbehind, '(?<=', 0, 4]
4549

4650
# Options
4751
include_examples 'scan', '(?-mix:abc)', 0 => [:group, :options, '(?-mix:', 0, 7]

0 commit comments

Comments
 (0)