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