Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vcfxb committed May 6, 2020
1 parent ab66e14 commit 8108f73
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fn p(f: Fragment) -> IResult<Fragment, Expression> {
}

#[test]
fn test_binary_expr_simple() {
test_should_succeed(
fn test_binary_expr_simple<'a>() {
test_should_succeed::<Expression<'a>, _>(
p,
"2 + 2",
"",
Expand Down
13 changes: 7 additions & 6 deletions wright/src/grammar/parsers/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ pub fn test_ast_eq<T: AstEq>(
}

/// Run a specific test on a given parser.
fn run_test<'a, O, I, T>(
fn run_test<'a, O, T>(
parser: fn(Fragment) -> IResult<Fragment, O>,
src: &'static str,
should_fail: bool,
remaining: Option<&'static str>,
output_test: T
)
where
T: FnOnce(I) -> bool,
O: Into<I>
T: FnOnce(O) -> bool,
{
let mut f: Files<String> = Files::new();
let h: FileId = f.add("test", src.to_string());
Expand All @@ -54,12 +53,14 @@ where

/// Run a test on a parser using a certain input and expect it to succeed.
#[inline]
pub fn test_should_succeed<O, I: From<O>>(
pub fn test_should_succeed<O, T>(
parser: fn(Fragment) -> IResult<Fragment, O>,
src: &'static str,
remaining: &'static str,
output_test: impl Fn(I) -> bool
) {
output_test: T
)
where T: FnOnce(O) -> bool
{
run_test(parser, src, false, Some(remaining), output_test)
}

Expand Down

0 comments on commit 8108f73

Please sign in to comment.