@@ -485,15 +485,29 @@ mod tests {
485485 }
486486
487487 #[ test]
488- #[ ignore = "Missing parser support for lookaround" ]
489488 fn print_look_around ( ) {
490- roundtrip ( "(?<=)" , "(?<=(?:))" ) ;
491- roundtrip ( "(?<!)" , "(?<!(?:))" ) ;
489+ // we do not want to do a roundtrip: printed lookarounds are not
490+ // can contain capture groups which are unsupported by the parser.
491+ // TODO(shilangyu): is this a problem that some regexes are not
492+ // roundtrippable?
493+ fn test ( given : & str , expected : & str ) {
494+ let builder = ParserBuilder :: new ( ) ;
495+ let hir = builder. build ( ) . parse ( given) . unwrap ( ) ;
496+
497+ let mut printer = Printer :: new ( ) ;
498+ let mut dst = String :: new ( ) ;
499+ printer. print ( & hir, & mut dst) . unwrap ( ) ;
500+
501+ assert_eq ! ( expected, dst) ;
502+ }
503+
504+ test ( "(?<=)" , "(?<=(?:))" ) ;
505+ test ( "(?<!)" , "(?<!(?:))" ) ;
492506
493- roundtrip ( "(?<=a)" , "(?<=a)" ) ;
494- roundtrip ( "(?<!a)" , "(?<!a)" ) ;
507+ test ( "(?<=a)" , "(?<=a)" ) ;
508+ test ( "(?<!a)" , "(?<!a)" ) ;
495509
496- roundtrip ( "(?<=(?<!(?<!(?<=a))))" , "(?<=(?<!(?<!(?<=a))))" ) ;
510+ test ( "(?<=(?<!(?<!(?<=a))))" , "(?<=(?<!(?<!(?<=a))))" ) ;
497511 }
498512
499513 #[ test]
0 commit comments