finished circuit form
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
c235f9727f
commit
4b587f11ab
7 changed files with 144 additions and 53 deletions
|
|
@ -213,4 +213,45 @@ mod control_lib_tests {
|
|||
eval(&while_tree, &mut syms).unwrap();
|
||||
eval(&check_tree, &mut syms).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circuit_basic() {
|
||||
let document = "(if (circuit true (and true true) true) (def result 'passed') ())";
|
||||
let test = "result";
|
||||
|
||||
let doc_tree = lex(&document.to_string()).unwrap();
|
||||
let test_tree = lex(&test.to_string()).unwrap();
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
|
||||
eval(&doc_tree, &mut syms).unwrap();
|
||||
let res = eval(&test_tree, &mut syms);
|
||||
println!("{:#?}", res);
|
||||
res.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_circuit_fail() {
|
||||
let document = "(if (circuit true (and false true) true) (def result 'passed') ())";
|
||||
let test = "result";
|
||||
|
||||
let doc_tree = lex(&document.to_string()).unwrap();
|
||||
let test_tree = lex(&test.to_string()).unwrap();
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
|
||||
eval(&doc_tree, &mut syms).unwrap();
|
||||
if let Err(s) = eval(&test_tree, &mut syms) {
|
||||
assert_eq!(
|
||||
s,
|
||||
"error in call to result: undefined symbol: result".to_string()
|
||||
);
|
||||
} else {
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue