@@ -434,8 +434,10 @@ mod tests {
434
434
roundtrip ( "|" , "(?:|)" ) ;
435
435
roundtrip ( "||" , "(?:||)" ) ;
436
436
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))" ) ;
439
441
roundtrip ( "foo|bar|quux" , "(?:(?:foo)|(?:bar)|(?:quux))" ) ;
440
442
}
441
443
@@ -494,19 +496,19 @@ mod tests {
494
496
#[ test]
495
497
fn regression_repetition_alternation ( ) {
496
498
let expr = Hir :: concat ( alloc:: vec![
497
- Hir :: literal( "x " . as_bytes( ) ) ,
499
+ Hir :: literal( "ab " . as_bytes( ) ) ,
498
500
Hir :: repetition( hir:: Repetition {
499
501
min: 1 ,
500
502
max: None ,
501
503
greedy: true ,
502
504
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( ) ) ,
505
507
] ) ) ,
506
508
} ) ,
507
- Hir :: literal( "y " . as_bytes( ) ) ,
509
+ Hir :: literal( "gh " . as_bytes( ) ) ,
508
510
] ) ;
509
- assert_eq ! ( r"(?:x (?:a|b)+y )" , expr. to_string( ) ) ;
511
+ assert_eq ! ( r"(?:(?:ab)(?:(?:cd)|(?:ef))+(?:gh) )" , expr. to_string( ) ) ;
510
512
511
513
let expr = Hir :: concat ( alloc:: vec![
512
514
Hir :: look( hir:: Look :: Start ) ,
@@ -538,13 +540,13 @@ mod tests {
538
540
#[ test]
539
541
fn regression_alternation_concat ( ) {
540
542
let expr = Hir :: concat ( alloc:: vec![
541
- Hir :: literal( "a " . as_bytes( ) ) ,
543
+ Hir :: literal( "ab " . as_bytes( ) ) ,
542
544
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( ) ) ,
545
547
] ) ,
546
548
] ) ;
547
- assert_eq ! ( r"(?:a (?:b|c ))" , expr. to_string( ) ) ;
549
+ assert_eq ! ( r"(?:(?:ab)(?:(?:mn)|(?:xy) ))" , expr. to_string( ) ) ;
548
550
549
551
let expr = Hir :: concat ( alloc:: vec![
550
552
Hir :: look( hir:: Look :: Start ) ,
0 commit comments