Skip to content

Commit 23764ce

Browse files
committed
Fix hir::Lookaround printing and add test
1 parent 96548c1 commit 23764ce

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

regex-syntax/src/hir/print.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ impl<W: fmt::Write> Visitor for Writer<W> {
228228
}
229229
},
230230
HirKind::Lookaround(hir::Lookaround::PositiveLookBehind(_)) => {
231-
self.wtr.write_str(r"(?<=)")?;
231+
self.wtr.write_str(r"(?<=")?;
232232
}
233233
HirKind::Lookaround(hir::Lookaround::NegativeLookBehind(_)) => {
234-
self.wtr.write_str(r"(?<!)")?;
234+
self.wtr.write_str(r"(?<!")?;
235235
}
236236
HirKind::Capture(hir::Capture { ref name, .. }) => {
237237
self.wtr.write_str("(")?;
@@ -484,6 +484,18 @@ mod tests {
484484
roundtrip("((((a))))", "((((a))))");
485485
}
486486

487+
#[test]
488+
#[ignore = "Missing parser support for lookaround"]
489+
fn print_look_around() {
490+
roundtrip("(?<=)", "(?<=(?:))");
491+
roundtrip("(?<!)", "(?<!(?:))");
492+
493+
roundtrip("(?<=a)", "(?<=a)");
494+
roundtrip("(?<!a)", "(?<!a)");
495+
496+
roundtrip("(?<=(?<!(?<!(?<=a))))", "(?<=(?<!(?<!(?<=a))))");
497+
}
498+
487499
#[test]
488500
fn print_alternation() {
489501
roundtrip("|", "(?:(?:)|(?:))");

0 commit comments

Comments
 (0)