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