python_parser/
errors.rs

1#[derive(Copy, Clone, Debug, PartialEq, Eq)]
2#[repr(u32)]
3pub enum PyParseError {
4    UnexpectedIndent,
5    ExpectedIndent,
6    DisabledFeature,
7}
8impl From<PyParseError> for u32 {
9    fn from(e: PyParseError) -> u32 {
10        e as u32
11    }
12}
13
14#[cfg(test)]
15mod tests {
16    use nom;
17    use nom::types::CompleteStr;
18    use nom::{Context, ErrorKind};
19    use nom_locate::LocatedSpan;
20
21    use helpers::*;
22    use statements::statement;
23
24    #[test]
25    fn if_no_condition() {
26        assert_eq!(
27            statement(make_strspan("if:\n foo"), 0),
28            Err(nom::Err::Failure(Context::Code(
29                LocatedSpan {
30                    offset: 2,
31                    line: 1,
32                    fragment: CompleteStr(":\n foo")
33                },
34                ErrorKind::Alt
35            )))
36        );
37    }
38}