1use regex_automata::{dense, DFA};
2
3// A regression test for checking that minimization correctly translates
4// whether a state is a match state or not. Previously, it was possible for
5// minimization to mark a non-matching state as matching.
6#[test]
7fn minimize_sets_correct_match_states() {
8 let pattern =
9 // This is a subset of the grapheme matching regex. I couldn't seem
10 // to get a repro any smaller than this unfortunately.
11 r"(?x)
12 (?:
13 \p{gcb=Prepend}*
14 (?:
15 (?:
16 (?:
17 \p{gcb=L}*
18 (?:\p{gcb=V}+|\p{gcb=LV}\p{gcb=V}*|\p{gcb=LVT})
19 \p{gcb=T}*
20 )
21 |
22 \p{gcb=L}+
23 |
24 \p{gcb=T}+
25 )
26 |
27 \p{Extended_Pictographic}
28 (?:\p{gcb=Extend}*\p{gcb=ZWJ}\p{Extended_Pictographic})*
29 |
30 [^\p{gcb=Control}\p{gcb=CR}\p{gcb=LF}]
31 )
32 [\p{gcb=Extend}\p{gcb=ZWJ}\p{gcb=SpacingMark}]*
33 )
34 ";
35
36 let dfa = dense::Builder::new()
37 .minimize(true)
38 .anchored(true)
39 .build(pattern)
40 .unwrap();
41 assert_eq!(None, dfa.find(b"\xE2"));
42}
43