mark core as nostd

* implement custom hashmap to back symtable
* pass in print and read callbacks to keep stdlib pure
* use core / alloc versions of Box, Rc, Vec, etc
* replace pow func with libm

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2024-07-26 22:16:21 -07:00
parent 0c2aad2cb6
commit d6a0e68460
26 changed files with 493 additions and 288 deletions

View file

@ -102,7 +102,7 @@ mod eval_tests {
let rh_doc = "(apply (lambda (x) (car x)) (1 2 3))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&comparator.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(

View file

@ -7,7 +7,7 @@ mod append_lib_tests {
let document = "(cons () 1)";
let result = "(1)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -22,7 +22,7 @@ mod append_lib_tests {
let result = "(1 \"two\" 3.4)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -37,7 +37,7 @@ mod append_lib_tests {
let result = "(1 2 3)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -52,7 +52,7 @@ mod append_lib_tests {
let result = "(<nil>)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -67,7 +67,7 @@ mod append_lib_tests {
let result = "(\"test\" 1 2 3)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -82,7 +82,7 @@ mod append_lib_tests {
let result = "0";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -97,7 +97,7 @@ mod append_lib_tests {
let result = "3";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -111,7 +111,7 @@ mod append_lib_tests {
let document = "(car ())";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.err()
@ -130,7 +130,7 @@ mod append_lib_tests {
let result = "1";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -144,7 +144,7 @@ mod append_lib_tests {
let document = "(cdr ())";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
@ -164,7 +164,7 @@ mod append_lib_tests {
let result = "3";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
@ -183,7 +183,7 @@ mod append_lib_tests {
let result2 = "(2 3)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
let ch1 = lex(&check1.to_string()).unwrap();
@ -209,7 +209,7 @@ mod append_lib_tests {
let result2 = "(<nil>)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
let ch1 = lex(&check1.to_string()).unwrap();
@ -235,7 +235,7 @@ mod append_lib_tests {
let result2 = "(1 2)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
let ch1 = lex(&check1.to_string()).unwrap();
@ -261,7 +261,7 @@ mod append_lib_tests {
let result2 = "(<nil>)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
let ch1 = lex(&check1.to_string()).unwrap();
@ -284,7 +284,7 @@ mod append_lib_tests {
let result = "(3 2 1 \"test\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
@ -300,7 +300,7 @@ mod append_lib_tests {
let result = "(\"test\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
@ -316,7 +316,7 @@ mod append_lib_tests {
let result = "(<nil>)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
@ -332,7 +332,7 @@ mod append_lib_tests {
let result = "true";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
@ -348,7 +348,7 @@ mod append_lib_tests {
let result = "false";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)

View file

@ -7,7 +7,7 @@ mod bool_lib_tests {
let document = "(and true true true true true)";
let result = "true";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -21,7 +21,7 @@ mod bool_lib_tests {
let document = "(and true true false true true)";
let result = "false";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -35,7 +35,7 @@ mod bool_lib_tests {
let document = "(and false false false false false)";
let result = "false";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -49,7 +49,7 @@ mod bool_lib_tests {
let document = "(or true true true true true)";
let result = "true";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -63,7 +63,7 @@ mod bool_lib_tests {
let document = "(or true true false true true)";
let result = "true";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -77,7 +77,7 @@ mod bool_lib_tests {
let document = "(or false false false false false)";
let result = "false";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -91,7 +91,7 @@ mod bool_lib_tests {
let document = "(not true)";
let result = "false";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -107,7 +107,7 @@ mod bool_lib_tests {
let check = "(tester)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -145,7 +145,7 @@ mod bool_lib_tests {
let check = "(tester)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -177,7 +177,7 @@ mod bool_lib_tests {
let check = "(tester \"1\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -206,7 +206,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(b)
@ -221,7 +221,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)
@ -236,7 +236,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)
@ -251,7 +251,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)
@ -266,7 +266,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(b)
@ -281,7 +281,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(b)
@ -296,7 +296,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)
@ -311,7 +311,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(b)
@ -326,7 +326,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)
@ -341,7 +341,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(b)
@ -356,7 +356,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)
@ -371,7 +371,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(b)
@ -386,7 +386,7 @@ mod bool_lib_tests {
let test = lex(&document.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
if let Ctr::Bool(b) = *eval(&test, &mut syms).unwrap() {
assert!(!b)

View file

@ -6,7 +6,7 @@ mod control_lib_tests {
fn test_assert_t() {
let document = "(assert true)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
}
@ -14,7 +14,7 @@ mod control_lib_tests {
fn test_assert_f() {
let document = "(assert false)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert!(eval(&lex(&document.to_string()).unwrap(), &mut syms).is_err())
}
@ -23,7 +23,7 @@ mod control_lib_tests {
let document = "(if true 1 2)";
let result = 1;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -37,7 +37,7 @@ mod control_lib_tests {
let document = "(if false 1 2)";
let result = 2;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -51,7 +51,7 @@ mod control_lib_tests {
let document = "(if true (cons () 1) 2)";
let result = "(1)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -68,7 +68,7 @@ mod control_lib_tests {
temp)";
let result = "(\"1\" \"2\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -86,7 +86,7 @@ mod control_lib_tests {
let document2 = "global";
let result = "(\"hello world\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&document1.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(
*eval(&lex(&document2.to_string()).unwrap(), &mut syms)
@ -101,7 +101,7 @@ mod control_lib_tests {
let document = "(let ((temp \"1\")) temp (cons () temp \"2\"))";
let result = "(\"1\" \"2\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -120,7 +120,7 @@ mod control_lib_tests {
let result = "(\"1\" \"2\" \"3\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -148,7 +148,7 @@ mod control_lib_tests {
let check_tree = lex(&test_check.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&switch_tree, &mut syms).unwrap();
eval(&while_tree, &mut syms).unwrap();
@ -174,7 +174,7 @@ mod control_lib_tests {
let check_tree = lex(&test_check.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&switch_tree, &mut syms).unwrap();
eval(&while_tree, &mut syms).unwrap();
@ -200,7 +200,7 @@ mod control_lib_tests {
let check_tree = lex(&test_check.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&another_tree, &mut syms).unwrap();
eval(&switch_tree, &mut syms).unwrap();
@ -217,7 +217,7 @@ mod control_lib_tests {
let test_tree = lex(&test.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&doc_tree, &mut syms).unwrap();
let res = eval(&test_tree, &mut syms);
@ -234,7 +234,7 @@ mod control_lib_tests {
let test_tree = lex(&test.to_string()).unwrap();
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&doc_tree, &mut syms).unwrap();
assert_eq!(

View file

@ -9,7 +9,7 @@ mod decl_lib_tests {
let result = "(1)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
let res = *eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -23,7 +23,7 @@ mod decl_lib_tests {
let result = "((1))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
let res = *eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -37,7 +37,7 @@ mod decl_lib_tests {
let result = "1";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
let res = *eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -52,7 +52,7 @@ mod decl_lib_tests {
let result = "(\"2\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -68,7 +68,7 @@ mod decl_lib_tests {
let doc3 = "(test)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -95,7 +95,7 @@ mod decl_lib_tests {
let res2 = "(\"2\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -117,7 +117,7 @@ mod decl_lib_tests {
(eq? test \"one\")))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -135,7 +135,7 @@ mod decl_lib_tests {
let result = "1";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
let res = *eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
@ -148,7 +148,7 @@ mod decl_lib_tests {
let doc2 = "(set? test)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let def_tree = lex(&doc1.to_string()).unwrap();
let set_tree = lex(&doc2.to_string()).unwrap();
@ -162,7 +162,7 @@ mod decl_lib_tests {
fn test_isset_false() {
let doc = "(set? test)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let set_tree = lex(&doc.to_string()).unwrap();
if let Ctr::Bool(b) = *eval(&set_tree, &mut syms).unwrap() {
assert!(!b);
@ -175,7 +175,7 @@ mod decl_lib_tests {
let doc2 = "(env)";
let doc3 = "t";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let set_tree = lex(&doc1.to_string()).unwrap();
let env_tree = lex(&doc2.to_string()).unwrap();
let tst_tree = lex(&doc3.to_string()).unwrap();
@ -189,7 +189,7 @@ mod decl_lib_tests {
let document = "(quote (add 1 2))";
let result = "(add 1 2)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -205,7 +205,7 @@ mod decl_lib_tests {
(eval stored-tree)))";
let result = "3";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -219,7 +219,7 @@ mod decl_lib_tests {
let document = "(eval (1 2 3))";
let result = "(1 2 3)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -232,7 +232,7 @@ mod decl_lib_tests {
fn test_lambda_str_equivalency_list() {
let document = "(lambda (x y) (add x y))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -245,7 +245,7 @@ mod decl_lib_tests {
fn test_lambda_str_equivalency_no_args() {
let document = "(lambda () (add 1 2))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -258,7 +258,7 @@ mod decl_lib_tests {
fn test_lambda_inline_call() {
let document = "((lambda (x y) (add x y)) 1 2)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let it = *eval(
&lex(&document.to_string()).unwrap(),
&mut syms).unwrap();
@ -274,7 +274,7 @@ mod decl_lib_tests {
let document = "(let ((adder (lambda (x y) (add x y))))
(adder 1 2))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let it = *eval(
&lex(&document.to_string()).unwrap(),
&mut syms).unwrap();
@ -291,7 +291,7 @@ mod decl_lib_tests {
(def adder \"my adder\" (lambda (x y) (add x y)))
(adder 1 2))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let it = *eval(
&lex(&document.to_string()).unwrap(),
&mut syms).unwrap();
@ -309,7 +309,7 @@ mod decl_lib_tests {
(def adder \"my adder\" (lambda (x) (add x 1)))
(appl adder 2))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let it = *eval(
&lex(&document.to_string()).unwrap(),
&mut syms).unwrap();
@ -326,7 +326,7 @@ mod decl_lib_tests {
let highly_inadvisable = "(set-doc (q help) \"help\")";
let document = "(get-doc (q help))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let _ = *eval(
&lex(&highly_inadvisable.to_string()).unwrap(),
&mut syms).unwrap();
@ -344,7 +344,7 @@ mod decl_lib_tests {
fn test_eval_quote() {
let doc = "(eval (quote (add 1 1)))";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&doc.to_string()).unwrap(), &mut syms).unwrap().to_string(),
2.to_string()

View file

@ -1,6 +1,7 @@
mod math_lib_tests {
use flesh::ast::{eval, lex, Ctr, SymTable};
use flesh::stdlib::static_stdlib;
use libm::pow;
#[test]
fn test_add_chain() {
@ -8,7 +9,7 @@ mod math_lib_tests {
let result = "10";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -23,7 +24,7 @@ mod math_lib_tests {
let result = "10.2";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -38,7 +39,7 @@ mod math_lib_tests {
let result = "24";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -53,7 +54,7 @@ mod math_lib_tests {
let result = "-8.2";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -68,7 +69,7 @@ mod math_lib_tests {
let result = "2";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -83,7 +84,7 @@ mod math_lib_tests {
let result = "10";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -98,7 +99,7 @@ mod math_lib_tests {
let result = "10";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -113,7 +114,7 @@ mod math_lib_tests {
let result = "10";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -128,7 +129,7 @@ mod math_lib_tests {
let result = "10.3";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -140,10 +141,10 @@ mod math_lib_tests {
#[test]
fn test_ii_exp() {
let document = "(exp 7 20)";
let result = 7i128.pow(20);
let result = pow(7 as f64, 20 as f64);
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -158,7 +159,7 @@ mod math_lib_tests {
let result = f64::powf(1f64, 10.2);
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -169,26 +170,26 @@ mod math_lib_tests {
#[test]
fn test_fi_exp() {
let document = "(exp 1.2 5)";
let result = f64::powf(1.2, 5f64);
let document = "(exp 10.2 1)";
let result = pow(10.2 as f64, 1 as f64);
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
format!("{:.5}", result),
result.to_string(),
);
}
#[test]
fn test_ff_exp() {
let document = "(exp 1.3 1.5)";
let result = f64::powf(1.3, 1.5);
let document = "(exp 1.4 1.5)";
let result = pow(1.4, 1.5);
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -206,7 +207,7 @@ mod math_lib_tests {
let result2 = "1";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(
*eval(&lex(&check1.to_string()).unwrap(), &mut syms)
@ -229,7 +230,7 @@ mod math_lib_tests {
let result1 = "2";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(
*eval(&lex(&check1.to_string()).unwrap(), &mut syms)
@ -245,7 +246,7 @@ mod math_lib_tests {
let check1 = "(car test)";
let result1 = "3";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(
*eval(&lex(&check1.to_string()).unwrap(), &mut syms)
@ -262,7 +263,7 @@ mod math_lib_tests {
let result1 = "2";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let _ = *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap();
assert_eq!(
*eval(&lex(&check1.to_string()).unwrap(), &mut syms)
@ -278,7 +279,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -293,7 +294,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -308,7 +309,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -323,7 +324,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -338,7 +339,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -353,7 +354,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -368,7 +369,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -383,7 +384,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -398,7 +399,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -413,7 +414,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -428,7 +429,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -443,7 +444,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -458,7 +459,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -473,7 +474,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -488,7 +489,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -503,7 +504,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -518,7 +519,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -533,7 +534,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -548,7 +549,7 @@ mod math_lib_tests {
let result = false;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -563,7 +564,7 @@ mod math_lib_tests {
let result = true;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -579,7 +580,7 @@ mod math_lib_tests {
let check = "(tester)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -617,7 +618,7 @@ mod math_lib_tests {
let check = "(tester)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -649,7 +650,7 @@ mod math_lib_tests {
let check = "(tester \"1\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -679,7 +680,7 @@ mod math_lib_tests {
let check = "(tester)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -717,7 +718,7 @@ mod math_lib_tests {
let check = "(tester)";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();
@ -749,7 +750,7 @@ mod math_lib_tests {
let check = "(tester \"1\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_tree = lex(&document.to_string()).unwrap();
let change_tree = lex(&change.to_string()).unwrap();

View file

@ -7,7 +7,7 @@ mod str_lib_tests {
let document = "(concat \"test\")";
let result = "\"test\"";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -21,7 +21,7 @@ mod str_lib_tests {
let document = "(concat \"test\" 1 2 3)";
let result = "\"test123\"";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -35,7 +35,7 @@ mod str_lib_tests {
let document = "(concat)";
let result = "\"\"";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -49,7 +49,7 @@ mod str_lib_tests {
let document = "(strlen \"test\")";
let result = 4;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -63,7 +63,7 @@ mod str_lib_tests {
let document = "(strlen 1000)";
let result = 4;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -77,7 +77,7 @@ mod str_lib_tests {
let document = "(strlen 10.2)";
let result = 4;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -91,7 +91,7 @@ mod str_lib_tests {
let document = "(strlen (1 2 3))";
let result = 7;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -105,7 +105,7 @@ mod str_lib_tests {
let document = "(strlen true)";
let result = 4;
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -119,7 +119,7 @@ mod str_lib_tests {
let document = "(string 4)";
let result = "\"4\"";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -133,7 +133,7 @@ mod str_lib_tests {
let document = "(string (1 2 3))";
let result = "\"(1 2 3)\"";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -147,7 +147,7 @@ mod str_lib_tests {
let document = "(substr? \"bigger\" \"ger\")";
let result = "true";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -161,7 +161,7 @@ mod str_lib_tests {
let document = "(substr? \"smaller\" \"ger\")";
let result = "false";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -175,7 +175,7 @@ mod str_lib_tests {
let document = "(split \"one.two.three\" \".\")";
let result = "(\"one\" \"two\" \"three\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -189,7 +189,7 @@ mod str_lib_tests {
let document = "(split \"one:d:two:d:three\" \":d:\")";
let result = "(\"one\" \"two\" \"three\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -203,7 +203,7 @@ mod str_lib_tests {
let document = "(split \"one.two.three\" \"-\")";
let result = "(\"one.two.three\")";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -217,7 +217,7 @@ mod str_lib_tests {
let document = "(substr \"test\" 0 4)";
let result = "\"test\"";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
@ -231,7 +231,7 @@ mod str_lib_tests {
let document = "(substr \"test\" -1 3)";
let result = "start index cannot be negative";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_res= eval(&lex(&document.to_string()).unwrap(), &mut syms);
if let Err(e) = doc_res {
assert_eq!(
@ -248,7 +248,7 @@ mod str_lib_tests {
let document = "(substr \"test\" 1 -3)";
let result = "end index cannot be negative";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_res= eval(&lex(&document.to_string()).unwrap(), &mut syms);
if let Err(e) = doc_res {
assert_eq!(
@ -265,7 +265,7 @@ mod str_lib_tests {
let document = "(substr \"test\" 5 3)";
let result = "start index larger than source string";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_res= eval(&lex(&document.to_string()).unwrap(), &mut syms);
if let Err(e) = doc_res {
assert_eq!(
@ -282,7 +282,7 @@ mod str_lib_tests {
let document = "(substr \"test\" 1 5)";
let result = "end index larger than source string";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_res= eval(&lex(&document.to_string()).unwrap(), &mut syms);
if let Err(e) = doc_res {
assert_eq!(
@ -299,7 +299,7 @@ mod str_lib_tests {
let document = "(substr \"test\" 3 2)";
let result = "end index must be larger than start index";
let mut syms = SymTable::new();
static_stdlib(&mut syms);
static_stdlib(&mut syms, |_: &String| (), || String::new());
let doc_res= eval(&lex(&document.to_string()).unwrap(), &mut syms);
if let Err(e) = doc_res {
assert_eq!(