more complex tests

This commit is contained in:
Aidan Hahn 2021-07-19 23:59:03 -07:00
parent df5cb47cb4
commit 2c30975571
No known key found for this signature in database
GPG key ID: 327711E983899316
6 changed files with 179 additions and 320 deletions

View file

@ -1,4 +1,4 @@
mod func_tests {
mod eval_tests {
use std::rc::Rc;
use std::cell::RefCell;
use relish::ast::{Ctr, Function, Operation, ExternalOperation};
@ -117,12 +117,30 @@ mod func_tests {
}
}
/*
#[test]
fn eval_embedded_func_calls() {
let test_doc = "1".to_string();
let test_doc = "('one' (echo (echo 'unwrap_me')))".to_string();
let output = "('one' 'unwrap_me')";
let test_external_func: Function = Function{
name: String::from("echo"),
loose_syms: false,
eval_lazy: false,
args: Args::Lazy(1),
function: Operation::External(
ExternalOperation{
arg_syms: vec!["input".to_string()],
ast: new_ast(Ctr::Seg(new_ast(Ctr::Symbol("input".to_string()), Ctr::None)), Ctr::None)
}
)
};
let ft = Rc::new(RefCell::new(FTable::new()));
let vt = Rc::new(RefCell::new(VTable::new()));
if let Some(s) = func_declare(ft.clone(),
Rc::new(RefCell::new(test_external_func))) {
print!("Error declaring external func: {}", s);
assert!(false);
}
match lex(test_doc) {
Err(e) => {
@ -137,14 +155,22 @@ mod func_tests {
assert!(false)
},
Ok(reduced_ast) => {
// write tests here
Ok(reduced) => {
if let Ctr::Seg(reduced_ast) = reduced {
let out_doc = ast_to_string(reduced_ast);
if out_doc != output {
print!("Erroneous output: {}\n", out_doc);
assert!(false)
}
}
}
}
}
}
}
/*
#[test]
fn eval_bad_vars() {
let test_doc = "1".to_string();