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:
parent
0c2aad2cb6
commit
d6a0e68460
26 changed files with 493 additions and 288 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue