mirror of
https://gitee.com/openharmony/third_party_rust_nom
synced 2024-11-23 07:29:54 +00:00
the regexp_macros is not used anymore
fix the issues related unit tests that were not compiled anymore
This commit is contained in:
parent
8098465542
commit
8a4efe51e3
@ -63,7 +63,7 @@ doc-comment = "0.3"
|
||||
version_check = "0.9"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = [ "alloc", "std", "regexp", "regexp_macros", "lexical"]
|
||||
features = [ "alloc", "std", "regexp", "lexical"]
|
||||
all-features = true
|
||||
|
||||
[profile.bench]
|
||||
@ -106,7 +106,7 @@ required-features = ["alloc"]
|
||||
|
||||
[[test]]
|
||||
name = "issues"
|
||||
required-features = ["alloc", "regexp_macros"]
|
||||
required-features = ["alloc"]
|
||||
|
||||
[[test]]
|
||||
name = "json"
|
||||
|
@ -217,7 +217,6 @@ There are a few compilation features:
|
||||
|
||||
* `std`: (activated by default) if disabled, nom can work in `no_std` builds
|
||||
* `regexp`: Enables regular expression parsers with the `regex` crate
|
||||
* `regexp_macros`: Enables regular expression parsers with the `regex` and `regex_macros` crates. Regular expressions can be defined at compile time, but it requires a nightly version of rustc
|
||||
|
||||
You can activate those features like this:
|
||||
|
||||
|
@ -22,7 +22,7 @@ pub fn take_char(input: &[u8]) -> IResult<&[u8], char> {
|
||||
if !input.is_empty() {
|
||||
Ok((&input[1..], input[0] as char))
|
||||
} else {
|
||||
Err(Err::Incomplete(Needed::Size(1)))
|
||||
Err(Err::Incomplete(Needed::new(1)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,13 +140,13 @@ fn issue_152() {
|
||||
fn take_till_issue() {
|
||||
named!(nothing, take_till!(call!(|_| true)));
|
||||
|
||||
assert_eq!(nothing(b""), Err(Err::Incomplete(Needed::Size(1))));
|
||||
assert_eq!(nothing(b""), Err(Err::Incomplete(Needed::new(1))));
|
||||
assert_eq!(nothing(b"abc"), Ok((&b"abc"[..], &b""[..])));
|
||||
}
|
||||
|
||||
named!(
|
||||
issue_498<Vec<&[u8]>>,
|
||||
separated_nonempty_list!(opt!(space), tag!("abcd"))
|
||||
separated_list1!(opt!(space), tag!("abcd"))
|
||||
);
|
||||
|
||||
named!(issue_308(&str) -> bool,
|
||||
@ -194,7 +194,7 @@ fn issue_721() {
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
named!(issue_717<&[u8], Vec<&[u8]> >,
|
||||
separated_list!(tag!([0x0]), is_not!([0x0u8]))
|
||||
separated_list0!(tag!([0x0]), is_not!([0x0u8]))
|
||||
);
|
||||
|
||||
struct NoPartialEq {
|
||||
@ -254,7 +254,7 @@ named!(multi_617<&[u8], () >, fold_many0!( digits, (), |_, _| {}));
|
||||
named!(multi_617_fails<&[u8], () >, fold_many0!( take_while1!( is_digit ), (), |_, _| {}));
|
||||
|
||||
mod issue_647 {
|
||||
use nom::{error::ErrorKind, number::streaming::be_f64, Err};
|
||||
use nom::{error::Error, number::streaming::be_f64, Err};
|
||||
pub type Input<'a> = &'a [u8];
|
||||
|
||||
#[derive(PartialEq, Debug, Clone)]
|
||||
@ -266,8 +266,8 @@ mod issue_647 {
|
||||
fn list<'a, 'b>(
|
||||
input: Input<'a>,
|
||||
_cs: &'b f64,
|
||||
) -> Result<(Input<'a>, Vec<f64>), Err<(&'a [u8], ErrorKind)>> {
|
||||
separated_list!(input, complete!(tag!(",")), complete!(be_f64))
|
||||
) -> Result<(Input<'a>, Vec<f64>), Err<Error<&'a [u8]>>> {
|
||||
separated_list0!(input, complete!(tag!(",")), complete!(be_f64))
|
||||
}
|
||||
|
||||
named!(data<Input,Data>, map!(
|
||||
@ -299,8 +299,8 @@ fn issue_848_overflow_incomplete_bits_to_bytes() {
|
||||
|
||||
#[test]
|
||||
fn issue_942() {
|
||||
use nom::error::ParseError;
|
||||
pub fn parser<'a, E: ParseError<&'a str>>(i: &'a str) -> IResult<&'a str, usize, E> {
|
||||
use nom::error::{ParseError, ContextError};
|
||||
pub fn parser<'a, E: ParseError<&'a str>+ContextError<&'a str>>(i: &'a str) -> IResult<&'a str, usize, E> {
|
||||
use nom::{character::complete::char, error::context, multi::many0_count};
|
||||
many0_count(context("char_a", char('a')))(i)
|
||||
}
|
||||
@ -311,7 +311,7 @@ fn issue_942() {
|
||||
fn issue_many_m_n_with_zeros() {
|
||||
use nom::character::complete::char;
|
||||
use nom::multi::many_m_n;
|
||||
let parser = many_m_n::<_, _, (), _>(0, 0, char('a'));
|
||||
let mut parser = many_m_n::<_, _, (), _>(0, 0, char('a'));
|
||||
assert_eq!(parser("aaa"), Ok(("aaa", vec!())));
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ fn issue_1027_convert_error_panic_nonempty() {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let msg = convert_error(&input, err);
|
||||
let msg = convert_error(input, err);
|
||||
assert_eq!(
|
||||
msg,
|
||||
"0: at line 1:\na\n ^\nexpected \'b\', got end of input\n\n"
|
||||
|
Loading…
Reference in New Issue
Block a user