]>
git.proxmox.com Git - rustc.git/blob - vendor/regex-automata-0.2.0/tests/nfa/thompson/pikevm/suite.rs
4 pikevm
::{self, PikeVM}
,
6 MatchKind
, SyntaxConfig
,
8 use regex_syntax
as syntax
;
11 bstr
::{BString, ByteSlice}
,
12 CompiledRegex
, Match
, MatchKind
as TestMatchKind
, RegexTest
, RegexTests
,
13 SearchKind
as TestSearchKind
, TestResult
, TestRunner
,
16 use crate::{suite, Result}
;
18 /// Tests the default configuration of the hybrid NFA/DFA.
20 fn default() -> Result
<()> {
21 let builder
= PikeVM
::builder();
22 TestRunner
::new()?
.test_iter(suite()?
.iter(), compiler(builder
)).assert();
27 mut builder
: pikevm
::Builder
,
28 ) -> impl FnMut(&RegexTest
, &[BString
]) -> Result
<CompiledRegex
> {
29 move |test
, regexes
| {
32 .map(|r
| r
.to_str().map(|s
| s
.to_string()))
33 .collect
::<std
::result
::Result
<Vec
<String
>, _
>>()?
;
34 if !configure_pikevm_builder(test
, &mut builder
) {
35 return Ok(CompiledRegex
::skip());
37 let re
= builder
.build_many(®exes
)?
;
38 let mut cache
= re
.create_cache();
39 Ok(CompiledRegex
::compiled(move |test
| -> Vec
<TestResult
> {
40 run_test(&re
, &mut cache
, test
)
47 cache
: &mut pikevm
::Cache
,
49 ) -> Vec
<TestResult
> {
50 // let is_match = if re.is_match(cache, test.input()) {
51 // TestResult::matched()
53 // TestResult::no_match()
55 // let is_match = is_match.name("is_match");
57 let find_matches
= match test
.search_kind() {
58 TestSearchKind
::Earliest
=> {
59 TestResult
::skip().name("find_earliest_iter")
61 TestSearchKind
::Leftmost
=> {
63 .find_leftmost_iter(cache
, test
.input())
64 .take(test
.match_limit().unwrap_or(std
::usize::MAX
))
66 id
: m
.pattern().as_usize(),
70 TestResult
::matches(it
).name("find_leftmost_iter")
72 TestSearchKind
::Overlapping
=> {
73 TestResult
::skip().name("find_overlapping_iter")
76 // vec![is_match, find_matches]
80 /// Configures the given regex builder with all relevant settings on the given
83 /// If the regex test has a setting that is unsupported, then this returns
84 /// false (implying the test should be skipped).
85 fn configure_pikevm_builder(
87 builder
: &mut pikevm
::Builder
,
90 PikeVM
::config().anchored(test
.anchored()).utf8(test
.utf8());
92 .configure(pikevm_config
)
93 .syntax(config_syntax(test
))
94 .thompson(config_thompson(test
));
98 /// Configuration of a Thompson NFA compiler from a regex test.
99 fn config_thompson(test
: &RegexTest
) -> thompson
::Config
{
100 thompson
::Config
::new().utf8(test
.utf8())
103 /// Configuration of the regex parser from a regex test.
104 fn config_syntax(test
: &RegexTest
) -> SyntaxConfig
{
106 .case_insensitive(test
.case_insensitive())
107 .unicode(test
.unicode())