1
//! Reader tests for `#'x`, which reads as `(FUNCTION x)`.
2

            
3
use crate::ast::Expr;
4

            
5
use super::Reader;
6

            
7
#[test]
8
1
fn test_parse_function_quote() -> crate::error::Result<()> {
9
1
    let program = Reader::parse("#'foo #'(lambda (x) x)")?;
10
1
    assert_eq!(
11
1
        program.exprs,
12
1
        vec![
13
1
            Expr::List(vec![
14
1
                Expr::Symbol("FUNCTION".into()),
15
1
                Expr::Symbol("FOO".into())
16
1
            ]),
17
1
            Expr::List(vec![
18
1
                Expr::Symbol("FUNCTION".into()),
19
1
                Expr::List(vec![
20
1
                    Expr::Symbol("LAMBDA".into()),
21
1
                    Expr::List(vec![Expr::Symbol("X".into())]),
22
1
                    Expr::Symbol("X".into()),
23
1
                ]),
24
1
            ]),
25
        ]
26
    );
27
1
    Ok(())
28
1
}
29

            
30
#[test]
31
1
fn test_parse_function_quote_dangling_is_an_error() {
32
1
    assert!(Reader::parse("#'").is_err());
33
1
    assert!(Reader::parse("(#')").is_err());
34
1
}