Skip to content

Commit

Permalink
add missing test file
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Aug 4, 2015
1 parent a9ed82a commit 62908a2
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/issues.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#![feature(trace_macros)]
#[macro_use]
extern crate nom;

use nom::{IResult,Needed};

#[allow(dead_code)]
struct Range {
start: char,
end: char
}

pub fn take_char(input: &[u8]) -> IResult<&[u8], char> {
if input.len() > 0 {
IResult::Done(&input[1..], input[0] as char)
} else {
IResult::Incomplete(Needed::Size(1))
}
}

//trace_macros!(true);

#[allow(dead_code)]
named!(range<&[u8], Range>,
alt!(
chain!(
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() {
range(&b"abcd"[..]);
literal(&b"abcd"[..]);
}

//trace_macros!(false);

0 comments on commit 62908a2

Please sign in to comment.