Skip to content

Commit

Permalink
add tests from issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Aug 18, 2018
1 parent a1ec8e5 commit 0009b60
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion tests/issues.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern crate nom;
extern crate regex;

use nom::{space, Err, IResult, Needed, le_u64};
use nom::{space, Err, IResult, Needed, le_u64, is_digit};
use nom::types::{CompleteStr, CompleteByteSlice};

#[allow(dead_code)]
Expand Down Expand Up @@ -289,3 +289,41 @@ mod issue_780 {
escaped_transform!(call!(::nom::alpha), '\\', 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::{Err,be_f64};
pub type Input<'a> = &'a [u8];

#[derive(PartialEq, Debug, Clone)]
struct Data {
c: f64,
v: Vec<f64>
}

fn list<'a,'b>(input: Input<'a>, _cs: &'b f64) -> Result<(Input<'a>,Vec<f64>), Err<&'a [u8]>> {
separated_list_complete!(input, tag!(","),be_f64)
}

named!(data<Input,Data>, map!(
do_parse!(
c: be_f64 >>
tag!("\n") >>
v: call!(list,&c) >>
(c,v)
), |(c,v)| {
Data {
c: c,
v: v
}
}
));
}

named!(issue_775, take_till1!(|_| true));

0 comments on commit 0009b60

Please sign in to comment.