@@ -434,8 +434,10 @@ mod tests {
434434 roundtrip ( "|" , "(?:|)" ) ;
435435 roundtrip ( "||" , "(?:||)" ) ;
436436
437- roundtrip ( "a|b" , "(?:a|b)" ) ;
438- roundtrip ( "a|b|c" , "(?:a|b|c)" ) ;
437+ roundtrip ( "a|b" , "[ab]" ) ;
438+ roundtrip ( "ab|cd" , "(?:(?:ab)|(?:cd))" ) ;
439+ roundtrip ( "a|b|c" , "[a-c]" ) ;
440+ roundtrip ( "ab|cd|ef" , "(?:(?:ab)|(?:cd)|(?:ef))" ) ;
439441 roundtrip ( "foo|bar|quux" , "(?:(?:foo)|(?:bar)|(?:quux))" ) ;
440442 }
441443
@@ -494,19 +496,19 @@ mod tests {
494496 #[ test]
495497 fn regression_repetition_alternation ( ) {
496498 let expr = Hir :: concat ( alloc:: vec![
497- Hir :: literal( "x " . as_bytes( ) ) ,
499+ Hir :: literal( "ab " . as_bytes( ) ) ,
498500 Hir :: repetition( hir:: Repetition {
499501 min: 1 ,
500502 max: None ,
501503 greedy: true ,
502504 hir: Box :: new( Hir :: alternation( alloc:: vec![
503- Hir :: literal( "a " . as_bytes( ) ) ,
504- Hir :: literal( "b " . as_bytes( ) ) ,
505+ Hir :: literal( "cd " . as_bytes( ) ) ,
506+ Hir :: literal( "ef " . as_bytes( ) ) ,
505507 ] ) ) ,
506508 } ) ,
507- Hir :: literal( "y " . as_bytes( ) ) ,
509+ Hir :: literal( "gh " . as_bytes( ) ) ,
508510 ] ) ;
509- assert_eq ! ( r"(?:x (?:a|b)+y )" , expr. to_string( ) ) ;
511+ assert_eq ! ( r"(?:(?:ab)(?:(?:cd)|(?:ef))+(?:gh) )" , expr. to_string( ) ) ;
510512
511513 let expr = Hir :: concat ( alloc:: vec![
512514 Hir :: look( hir:: Look :: Start ) ,
@@ -538,13 +540,13 @@ mod tests {
538540 #[ test]
539541 fn regression_alternation_concat ( ) {
540542 let expr = Hir :: concat ( alloc:: vec![
541- Hir :: literal( "a " . as_bytes( ) ) ,
543+ Hir :: literal( "ab " . as_bytes( ) ) ,
542544 Hir :: alternation( alloc:: vec![
543- Hir :: literal( "b " . as_bytes( ) ) ,
544- Hir :: literal( "c " . as_bytes( ) ) ,
545+ Hir :: literal( "mn " . as_bytes( ) ) ,
546+ Hir :: literal( "xy " . as_bytes( ) ) ,
545547 ] ) ,
546548 ] ) ;
547- assert_eq ! ( r"(?:a (?:b|c ))" , expr. to_string( ) ) ;
549+ assert_eq ! ( r"(?:(?:ab)(?:(?:mn)|(?:xy) ))" , expr. to_string( ) ) ;
548550
549551 let expr = Hir :: concat ( alloc:: vec![
550552 Hir :: look( hir:: Look :: Start ) ,
0 commit comments