1
use nomiscript::{
2
    Reader, eval_program,
3
    runtime::{SymbolTable, Value},
4
};
5

            
6
2
fn eval_expr(code: &str) -> Result<Value, nomiscript::Error> {
7
2
    let program = Reader::parse(code)?;
8
2
    let mut symbols = SymbolTable::with_builtins();
9
2
    eval_program(&mut symbols, &program)
10
2
}
11

            
12
#[test]
13
1
fn test_defstruct_creates_functions() {
14
1
    let code = r"
15
1
    (defstruct person name age)
16
1
    T
17
1
    ";
18
1
    let result = eval_expr(code);
19
1
    assert!(result.is_ok(), "DEFSTRUCT should succeed and return T");
20
1
}
21

            
22
#[test]
23
1
fn test_defstruct_constructor_exists() {
24
1
    let code = r"
25
1
    (defstruct person name age)
26
1
    (quote (make-person))
27
1
    ";
28
1
    let result = eval_expr(code);
29
1
    assert!(result.is_ok(), "Constructor function should exist");
30
1
}