aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/syntax.rs
blob: abf7309bf4b0aaae00faa658ca8dcf064edac282 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pub mod ast;
pub mod parse;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn parse_valid() {
        assert!(parse::parse("").is_ok());
        assert!(parse::parse("a").is_ok());
        assert!(parse::parse("ab").is_ok());
        assert!(parse::parse("abc").is_ok());
        assert!(parse::parse("a|b").is_ok());
        assert!(parse::parse("a|b*").is_ok());
        assert!(parse::parse("(a|b)*").is_ok());
        assert!(parse::parse("(((a|b)))*").is_ok());
        assert!(parse::parse("a*b*").is_ok());
    }

    #[test]
    fn parse_invalid() {
        assert!(parse::parse("(").is_err());
        assert!(parse::parse("()))").is_err());
        assert!(parse::parse("(((())").is_err());
    }
}