Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-03-01 11:38:02 -08:00
parent ecbc47d4fe
commit bc09cb07b1
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
17 changed files with 236 additions and 217 deletions

View file

@ -1,6 +1,6 @@
mod eval_tests {
use relish::ast::{eval, lex, SymTable};
use relish::ast::{Args, Symbol, Ctr, Seg, ValueType, UserFn};
use relish::ast::{Args, Ctr, Seg, Symbol, UserFn, ValueType};
#[test]
fn eval_simple() {
@ -58,11 +58,12 @@ mod eval_tests {
name: String::from("echo"),
args: Args::Lazy(1),
conditional_branches: false,
value: ValueType::FuncForm( UserFn {
value: ValueType::FuncForm(UserFn {
arg_syms: vec!["input".to_string()],
ast: Box::new(Seg::from(
Box::from(Ctr::Symbol("input".to_string())),
Box::from(Ctr::None))),
Box::from(Ctr::Symbol("input".to_string())),
Box::from(Ctr::None),
)),
}),
};
@ -93,15 +94,16 @@ mod eval_tests {
let output = "('one' 'unwrap_me')";
let mut syms = SymTable::new();
let test_external_func: Symbol = Symbol{
let test_external_func: Symbol = Symbol {
name: String::from("echo"),
args: Args::Lazy(1),
conditional_branches: false,
value: ValueType::FuncForm( UserFn {
value: ValueType::FuncForm(UserFn {
arg_syms: vec!["input".to_string()],
ast: Box::new(Seg::from(
Box::from(Ctr::Symbol("input".to_string())),
Box::from(Ctr::None))),
Box::from(Ctr::Symbol("input".to_string())),
Box::from(Ctr::None),
)),
}),
};
@ -137,7 +139,7 @@ mod eval_tests {
Ok(initial_ast) => match eval(&initial_ast, &mut syms) {
Err(e) => {
assert_eq!(e,"error in call to undefined: undefined symbol: undefined")
assert_eq!(e, "error in call to undefined: undefined symbol: undefined")
}
Ok(reduced) => {