Skip to content

Commit b25b38d

Browse files
max-sixtyBurntSushi
authored andcommitted
tests: clarify numbered group binding
This adds more tests to cover some corner cases in named/numbered group expansion. See also: #69
1 parent 172898a commit b25b38d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/expand.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn expand_bytes(
9292
/// `CaptureRef` represents a reference to a capture group inside some text.
9393
/// The reference is either a capture group name or a number.
9494
///
95-
/// It is also tagged with the position in the text immediately proceeding the
95+
/// It is also tagged with the position in the text following the
9696
/// capture reference.
9797
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
9898
struct CaptureRef<'a> {
@@ -204,6 +204,7 @@ mod tests {
204204
find!(find_cap_ref3, "$0", c!(0, 2));
205205
find!(find_cap_ref4, "$5", c!(5, 2));
206206
find!(find_cap_ref5, "$10", c!(10, 3));
207+
// see https://github.com/rust-lang/regex/pull/585 for more on characters following numbers
207208
find!(find_cap_ref6, "$42a", c!("42a", 4));
208209
find!(find_cap_ref7, "${42}a", c!(42, 5));
209210
find!(find_cap_ref8, "${42");
@@ -212,4 +213,8 @@ mod tests {
212213
find!(find_cap_ref11, "$");
213214
find!(find_cap_ref12, " ");
214215
find!(find_cap_ref13, "");
216+
find!(find_cap_ref14, "$1-$2", c!(1,2));
217+
find!(find_cap_ref15, "$1_$2", c!("1_",3));
218+
find!(find_cap_ref16, "$x-$y", c!("x",2));
219+
find!(find_cap_ref17, "$x_$y", c!("x_",3));
215220
}

0 commit comments

Comments
 (0)