mirror of
https://gitee.com/openharmony/third_party_rust_nom
synced 2024-11-27 01:30:32 +00:00
remove macro related tests for previous issues
The type-inference tests for macros are no longer needed.
This commit is contained in:
parent
7e2f70950e
commit
f54616848f
@ -81,9 +81,6 @@ name = "custom_errors"
|
||||
[[test]]
|
||||
name = "float"
|
||||
|
||||
[[test]]
|
||||
name = "inference"
|
||||
|
||||
[[test]]
|
||||
name = "ini"
|
||||
required-features = ["alloc"]
|
||||
|
@ -1,54 +0,0 @@
|
||||
//! test type inference issues in parsee compilation
|
||||
//#![feature(trace_macros)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_comparisons)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate nom;
|
||||
|
||||
use nom::character::{is_digit, streaming::alpha1 as alpha};
|
||||
use std::str;
|
||||
|
||||
// issue #617
|
||||
named!(multi<&[u8], () >, fold_many0!( take_while1!( is_digit ), (), |_, _| {}));
|
||||
|
||||
// issue #561
|
||||
#[cfg(feature = "alloc")]
|
||||
named!(
|
||||
value<Vec<Vec<&str>>>,
|
||||
do_parse!(
|
||||
first_line: map_res!(is_not!("\n"), std::str::from_utf8)
|
||||
>> rest:
|
||||
many_m_n!(
|
||||
0,
|
||||
1,
|
||||
separated_list0!(
|
||||
tag!("\n\t"),
|
||||
map_res!(take_while!(call!(|c| c != b'\n')), std::str::from_utf8)
|
||||
)
|
||||
)
|
||||
>> (rest)
|
||||
)
|
||||
);
|
||||
|
||||
// issue #534
|
||||
#[cfg(feature = "alloc")]
|
||||
fn wrap_suffix(input: &Option<Vec<&[u8]>>) -> Option<String> {
|
||||
if input.is_some() {
|
||||
// I've tried both of the lines below individually and get the same error.
|
||||
Some("hello".to_string())
|
||||
//Some(str::from_utf8(u).expect("Found invalid UTF-8").to_string())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
named!(parse_suffix<&[u8],Option<String>>,do_parse!(
|
||||
u: opt!(many1!(alt!(
|
||||
complete!(tag!("%")) | complete!(tag!("#")) | complete!(tag!("@")) | complete!(alpha)
|
||||
))) >>
|
||||
(wrap_suffix(&u))
|
||||
));
|
151
tests/issues.rs
151
tests/issues.rs
@ -2,15 +2,7 @@
|
||||
#![allow(dead_code)]
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_closure))]
|
||||
|
||||
#[macro_use]
|
||||
extern crate nom;
|
||||
|
||||
use nom::{
|
||||
character::{is_digit, streaming::space1 as space},
|
||||
error::ErrorKind,
|
||||
number::streaming::le_u64,
|
||||
Err, IResult, Needed,
|
||||
};
|
||||
use nom::{error::ErrorKind, Err, IResult, Needed};
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct Range {
|
||||
@ -26,50 +18,6 @@ pub fn take_char(input: &[u8]) -> IResult<&[u8], char> {
|
||||
}
|
||||
}
|
||||
|
||||
//trace_macros!(true);
|
||||
|
||||
#[allow(dead_code)]
|
||||
named!(range<&[u8], Range>,
|
||||
alt!(
|
||||
do_parse!(
|
||||
start: take_char >>
|
||||
tag!("-") >>
|
||||
end: take_char >>
|
||||
(Range {
|
||||
start: start,
|
||||
end: end,
|
||||
})
|
||||
) |
|
||||
map!(
|
||||
take_char,
|
||||
|c| {
|
||||
Range {
|
||||
start: c,
|
||||
end: c,
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
#[allow(dead_code)]
|
||||
named!(literal<&[u8], Vec<char> >,
|
||||
map!(
|
||||
many1!(take_char),
|
||||
|cs| {
|
||||
cs
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn issue_58() {
|
||||
let _ = range(&b"abcd"[..]);
|
||||
let _ = literal(&b"abcd"[..]);
|
||||
}
|
||||
|
||||
//trace_macros!(false);
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
mod parse_int {
|
||||
use nom::HexDisplay;
|
||||
@ -144,25 +92,6 @@ fn take_till_issue() {
|
||||
assert_eq!(nothing(b"abc"), Ok((&b"abc"[..], &b""[..])));
|
||||
}
|
||||
|
||||
named!(
|
||||
issue_498<Vec<&[u8]>>,
|
||||
separated_list1!(opt!(space), tag!("abcd"))
|
||||
);
|
||||
|
||||
named!(issue_308(&str) -> bool,
|
||||
do_parse! (
|
||||
tag! ("foo") >>
|
||||
b: alt! (
|
||||
complete!(map! (tag! ("1"), |_: &str|->bool {true})) |
|
||||
value! (false)
|
||||
) >>
|
||||
(b) ));
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
fn issue_302(input: &[u8]) -> IResult<&[u8], Option<Vec<u64>>> {
|
||||
do_parse!(input, entries: cond!(true, count!(le_u64, 3)) >> (entries))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_655() {
|
||||
use nom::character::streaming::{line_ending, not_line_ending};
|
||||
@ -182,77 +111,11 @@ fn issue_655() {
|
||||
assert_eq!(twolines("foé\r\nbar\n"), Ok(("", ("foé", "bar"))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_721() {
|
||||
named!(f1<&str, u16>, parse_to!(u16));
|
||||
named!(f2<&str, String>, parse_to!(String));
|
||||
assert_eq!(f1("1234"), Ok(("", 1234)));
|
||||
assert_eq!(f2("foo"), Ok(("", "foo".to_string())));
|
||||
//assert_eq!(parse_to!("1234", u16), Ok(("", 1234)));
|
||||
//assert_eq!(parse_to!("foo", String), Ok(("", "foo".to_string())));
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
named!(issue_717<&[u8], Vec<&[u8]> >,
|
||||
separated_list0!(tag!([0x0]), is_not!([0x0u8]))
|
||||
);
|
||||
|
||||
struct NoPartialEq {
|
||||
value: i32,
|
||||
}
|
||||
|
||||
named!(issue_724<&str, i32>,
|
||||
do_parse!(
|
||||
metadata: permutation!(
|
||||
map!(tag!("hello"), |_| NoPartialEq { value: 1 }),
|
||||
map!(tag!("world"), |_| NoPartialEq { value: 2 })
|
||||
) >>
|
||||
(metadata.0.value + metadata.1.value)
|
||||
)
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn issue_752() {
|
||||
assert_eq!(
|
||||
Err::Error(("ab", nom::error::ErrorKind::ParseTo)),
|
||||
parse_to!("ab", usize).unwrap_err()
|
||||
)
|
||||
}
|
||||
|
||||
fn atom_specials(c: u8) -> bool {
|
||||
c == b'q'
|
||||
}
|
||||
|
||||
named!(
|
||||
capability<&str>,
|
||||
do_parse!(tag!(" ") >> _atom: map_res!(take_till1!(atom_specials), std::str::from_utf8) >> ("a"))
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn issue_759() {
|
||||
assert_eq!(capability(b" abcqd"), Ok((&b"qd"[..], "a")));
|
||||
}
|
||||
|
||||
named_args!(issue_771(count: usize)<Vec<u32>>,
|
||||
length_count!(value!(count), call!(nom::number::streaming::be_u32))
|
||||
);
|
||||
|
||||
/// This test is in a separate module to check that all required symbols are imported in
|
||||
/// `escaped_transform!()`. Without the module, the `use`-es of the current module would
|
||||
/// mask the error ('"Use of undeclared type or module `Needed`" in escaped_transform!').
|
||||
mod issue_780 {
|
||||
named!(issue_780<&str, String>,
|
||||
escaped_transform!(call!(::nom::character::streaming::alpha1), '\\', tag!("n"))
|
||||
);
|
||||
}
|
||||
|
||||
// issue 617
|
||||
named!(digits, take_while1!(is_digit));
|
||||
named!(multi_617<&[u8], () >, fold_many0!( digits, (), |_, _| {}));
|
||||
|
||||
// Sad :(
|
||||
named!(multi_617_fails<&[u8], () >, fold_many0!( take_while1!( is_digit ), (), |_, _| {}));
|
||||
|
||||
mod issue_647 {
|
||||
use nom::{error::Error, number::streaming::be_f64, Err};
|
||||
pub type Input<'a> = &'a [u8];
|
||||
@ -285,8 +148,6 @@ mod issue_647 {
|
||||
));
|
||||
}
|
||||
|
||||
named!(issue_775, take_till1!(|_| true));
|
||||
|
||||
#[test]
|
||||
fn issue_848_overflow_incomplete_bits_to_bytes() {
|
||||
named!(take, take!(0x2000000000000000));
|
||||
@ -338,16 +199,6 @@ fn issue_1027_convert_error_panic_nonempty() {
|
||||
);
|
||||
}
|
||||
|
||||
named!(issue_962<&[u8], Vec<&[u8]>>,
|
||||
fold_many0!(
|
||||
alt!(tag!("aaaa") | tag!("bbbb")),
|
||||
Vec::new(), |mut acc: Vec<_>, item| {
|
||||
acc.push(item);
|
||||
acc
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
#[test]
|
||||
fn issue_1231_bits_expect_fn_closure() {
|
||||
use nom::bits::{bits, complete::take};
|
||||
|
Loading…
Reference in New Issue
Block a user