Macro fails_with

macro_rules! fails_with {
    ( parser: $parser:ident, input: $string:expr, rule: $rules:tt :: $rule:tt,
      positives: $positives:expr, negatives: $negatives:expr, pos: $pos:expr ) => { ... };
}

Testing tool that compares produced errors.

This macro takes several arguments:

Examples

# #[macro_use]
# extern crate pest;
# use pest::Parser;
# use pest::error::Error;
# use pest::iterators::Pairs;
# fn main() {
# #[allow(non_camel_case_types)]
# #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
# enum Rule {
#     a,
#     b,
#     c
# }
#
# struct AbcParser;
#
# impl Parser<Rule> for AbcParser {
#     fn parse<'i>(_: Rule, input: &'i str) -> Result<Pairs<'i, Rule>, Error<Rule>> {
#         pest::state(input, |state| {
#             state.rule(Rule::a, |state| {
#                 state.skip(1).unwrap().rule(Rule::b, |s| {
#                     s.skip(1)
#                 }).unwrap().skip(1)
#             }).and_then(|state| {
#                 state.skip(1).unwrap().rule(Rule::c, |s| {
#                     s.match_string("e")
#                 })
#             })
#         })
#     }
# }
fails_with! {
    parser: AbcParser,
    input: "abcdf",
    rule: Rule::a,
    positives: vec![Rule::c],
    negatives: vec![],
    pos: 4
};
# }