WIP commit:
* Fix up project structures * combine vars and funcs table * make a place for old code that may be useful to reference * singleton pattern for sym table Commentary: When this change is finally finished I promise to use feature branches from here on out
This commit is contained in:
parent
b680e3ca9a
commit
ca4c557d95
32 changed files with 1092 additions and 616 deletions
|
|
@ -1,126 +0,0 @@
|
|||
mod str_lib_tests {
|
||||
use relish::ast::{eval, lex, Ctr, FTable, VTable};
|
||||
use relish::stdlib::get_stdlib;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn test_simple_concat() {
|
||||
let document = "(concat 'test')";
|
||||
let result = "test";
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let ft: Rc<RefCell<FTable>>;
|
||||
match get_stdlib(vt.clone()) {
|
||||
Ok(f) => ft = f,
|
||||
Err(s) => {
|
||||
ft = Rc::new(RefCell::new(FTable::new()));
|
||||
println!("Couldnt get stdlib: {}!", s);
|
||||
assert!(false)
|
||||
}
|
||||
}
|
||||
|
||||
match lex(document.to_string()) {
|
||||
Err(s) => {
|
||||
println!("Couldnt lex {}: {}\n", document, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(tree) => match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}\n", document, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(ctr) => match ctr {
|
||||
Ctr::Symbol(_) => assert!(false),
|
||||
Ctr::String(s) => assert_eq!(s, result),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(_) => assert!(false),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_poly_concat() {
|
||||
let document = "(concat 'test' 1 2 3)";
|
||||
let result = "test123";
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let ft: Rc<RefCell<FTable>>;
|
||||
match get_stdlib(vt.clone()) {
|
||||
Ok(f) => ft = f,
|
||||
Err(s) => {
|
||||
ft = Rc::new(RefCell::new(FTable::new()));
|
||||
println!("Couldnt get stdlib: {}!", s);
|
||||
assert!(false)
|
||||
}
|
||||
}
|
||||
|
||||
match lex(document.to_string()) {
|
||||
Err(s) => {
|
||||
println!("Couldnt lex {}: {}\n", document, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(tree) => match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}\n", document, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(ctr) => match ctr {
|
||||
Ctr::Symbol(_) => assert!(false),
|
||||
Ctr::String(s) => assert_eq!(s, result),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(_) => assert!(false),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_empty_concat() {
|
||||
let document = "(concat)";
|
||||
let result = "";
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let ft: Rc<RefCell<FTable>>;
|
||||
match get_stdlib(vt.clone()) {
|
||||
Ok(f) => ft = f,
|
||||
Err(s) => {
|
||||
ft = Rc::new(RefCell::new(FTable::new()));
|
||||
println!("Couldnt get stdlib: {}!", s);
|
||||
assert!(false)
|
||||
}
|
||||
}
|
||||
|
||||
match lex(document.to_string()) {
|
||||
Err(s) => {
|
||||
println!("Couldnt lex {}: {}\n", document, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(tree) => match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}\n", document, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(ctr) => match ctr {
|
||||
Ctr::Symbol(_) => assert!(false),
|
||||
Ctr::String(s) => assert_eq!(s, result),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(_) => assert!(false),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue