Assert, Exit builtins

* Builtins for assert and exit are added
* Tests for assert are added
* file operations from previous MR are added to documents
* assert and exit are added to documents
This commit is contained in:
Ava Apples Affine 2023-06-20 01:25:19 +00:00
parent 270cc32572
commit 2cd5016c1d
6 changed files with 119 additions and 34 deletions

View file

@ -2,6 +2,24 @@ mod control_lib_tests {
use relish::ast::{eval, lex, SymTable};
use relish::stdlib::{dynamic_stdlib, static_stdlib};
#[test]
fn test_assert_t() {
let document = "(assert true)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
dynamic_stdlib(&mut syms, None);
eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
}
#[test]
fn test_assert_f() {
let document = "(assert false)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
dynamic_stdlib(&mut syms, None);
assert!(eval(&lex(&document.to_string()).unwrap(), &mut syms).is_err())
}
#[test]
fn test_if_first_case_singlet() {
let document = "(if true 1 2)";