rexile 0.5.7

A blazing-fast regex engine with 22x faster compilation and optimized case-insensitive matching
Documentation
use rexile::Pattern;

#[test]
fn test_unicode_arrow() {
    // Unicode arrow β†’ is 3 bytes (226, 134, 146)
    let input = "// Comment β†’ Next\nrule Test";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some(), "Should match 'rule Test'");
    let (start, end) = result.unwrap();
    assert_eq!(&input[start..end], "rule Test");
}

#[test]
fn test_emoji() {
    // Emoji πŸš€ is 4 bytes
    let input = "πŸš€ Fast rule\nrule Test {}";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some(), "Should find at least one match");
    // Note: Could match either "rule\nrule" or "rule Test" depending on position
    // Both are valid matches for this pattern
}

#[test]
fn test_cjk_characters() {
    // Chinese characters (θ§„εˆ™ = rule)
    let input = "θ§„εˆ™ (rule in Chinese)\nrule Test";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some(), "Should find a match");
    // Note: Could match "rule in" or "rule Test" - both valid
}

#[test]
fn test_math_symbols() {
    // Math symbols: βˆ‘ ∫ βˆ‚ β†’ ← ↔
    let input = "βˆ‘βˆ«βˆ‚ β†’ ← ↔\nrule Test";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some(), "Should match 'rule Test'");
    let (start, end) = result.unwrap();
    assert_eq!(&input[start..end], "rule Test");
}

#[test]
fn test_vietnamese_text() {
    // Vietnamese with diacritics
    let input = "// TiαΊΏng Việt 123\nrule Test {}";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some(), "Should match 'rule Test'");
    let (start, end) = result.unwrap();
    assert_eq!(&input[start..end], "rule Test");
}

#[test]
fn test_grl_with_unicode() {
    // GRL file with Unicode arrow in comment
    let grl = "// Rule: Amount < 2M + COD β†’ Auto approve\nrule \"AutoApprove\" salience 80 {}";
    let p = Pattern::new(r#"rule\s+"[^"]+""#).unwrap();
    let result = p.find(grl);
    assert!(result.is_some(), "Should match rule with quoted name");
    let (start, end) = result.unwrap();
    assert_eq!(&grl[start..end], "rule \"AutoApprove\"");
}

#[test]
fn test_multiple_unicode_chars() {
    // Mix of various Unicode: emoji, CJK, arrows, math
    let input = "🌍 World δΈ–η•Œ β†’ βˆ‘ test\nrule Test {}";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some(), "Should match 'rule Test'");
    let (start, end) = result.unwrap();
    assert_eq!(&input[start..end], "rule Test");
}

#[test]
fn test_unicode_in_middle_of_match() {
    // Pattern that crosses Unicode boundaries
    let input = "test→abc\nrule Test";
    let p = Pattern::new(r"rule\s+\w+").unwrap();
    let result = p.find(input);
    assert!(result.is_some());
}