Skip to content

Commit

Permalink
move more expressions into expr::tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vthriller committed Jan 12, 2018
1 parent 3cb0e12 commit d46f3f0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
40 changes: 40 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,45 @@ mod tests {
)
))
);

assert_eq!(
expression(&b"foo + bar - baz <= quux + xyzzy"[..]),
Done(&b""[..], operator(
operator(
operator(vector("foo"), Plus, vector("bar")),
Minus,
vector("baz"),
),
Le,
operator(vector("quux"), Plus, vector("xyzzy")),
))
);

assert_eq!(
expression(&b"foo + bar % baz"[..]),
Done(&b""[..], operator(
vector("foo"),
Plus,
operator(vector("bar"), Mod, vector("baz")),
))
);

assert_eq!(
expression(&b"x^y^z"[..]),
Done(&b""[..], operator(
vector("x"),
Pow,
operator(vector("y"), Pow, vector("z")),
))
);

assert_eq!(
expression(&b"(a+b)*c"[..]),
Done(&b""[..], operator(
operator(vector("a"), Plus, vector("b")),
Mul,
vector("c"),
))
);
}
}
4 changes: 0 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ fn show<O: Debug, E: Debug>(f: fn(&[u8]) -> IResult<&[u8], O, E>, s: &str) {
}

fn main() {
show(expr::expression, "foo + bar - baz <= quux + xyzzy");
show(expr::expression, "foo + bar % baz");
show(expr::expression, "x^y^z");
show(expr::expression, "(a+b)*c");
}

0 comments on commit d46f3f0

Please sign in to comment.