refmt
This commit is contained in:
parent
f805290a4b
commit
be73b0b828
17 changed files with 588 additions and 675 deletions
|
|
@ -1,9 +1,9 @@
|
|||
mod eval_tests {
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
use relish::ast::{Ctr, Function, Operation, ExternalOperation};
|
||||
use relish::ast::{new_ast, lex, eval, VTable, FTable, ast_to_string};
|
||||
use relish::ast::{ast_to_string, eval, lex, new_ast, FTable, VTable};
|
||||
use relish::ast::{func_declare, Args};
|
||||
use relish::ast::{Ctr, ExternalOperation, Function, Operation};
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
// TODO: write generalized testing routine on top of list of inputs
|
||||
|
||||
|
|
@ -17,22 +17,20 @@ mod eval_tests {
|
|||
Err(e) => {
|
||||
println!("Lexing error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
}
|
||||
|
||||
Ok(initial_ast) => {
|
||||
match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
Ok(initial_ast) => match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
}
|
||||
|
||||
Ok(reduced) => {
|
||||
if let Ctr::Seg(reduced_ast) = reduced {
|
||||
assert_eq!(ast_to_string(reduced_ast), test_doc)
|
||||
}
|
||||
Ok(reduced) => {
|
||||
if let Ctr::Seg(reduced_ast) = reduced {
|
||||
assert_eq!(ast_to_string(reduced_ast), test_doc)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,22 +44,20 @@ mod eval_tests {
|
|||
Err(e) => {
|
||||
println!("Lexing error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
}
|
||||
|
||||
Ok(initial_ast) => {
|
||||
match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
Ok(initial_ast) => match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
}
|
||||
|
||||
Ok(reduced) => {
|
||||
if let Ctr::Seg(reduced_ast) = reduced {
|
||||
assert_eq!(ast_to_string(reduced_ast), test_doc)
|
||||
}
|
||||
Ok(reduced) => {
|
||||
if let Ctr::Seg(reduced_ast) = reduced {
|
||||
assert_eq!(ast_to_string(reduced_ast), test_doc)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -69,23 +65,23 @@ mod eval_tests {
|
|||
fn eval_function_call() {
|
||||
let test_doc = "('one' (echo 'unwrap_me'))".to_string();
|
||||
let output = "('one' 'unwrap_me')";
|
||||
let test_external_func: Function = Function{
|
||||
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)
|
||||
}
|
||||
)
|
||||
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))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(test_external_func))) {
|
||||
print!("Error declaring external func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
|
|
@ -94,26 +90,24 @@ mod eval_tests {
|
|||
Err(e) => {
|
||||
println!("Lexing error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
}
|
||||
|
||||
Ok(initial_ast) => {
|
||||
match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
Ok(initial_ast) => match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -121,23 +115,23 @@ mod eval_tests {
|
|||
fn eval_embedded_func_calls() {
|
||||
let test_doc = "('one' (echo (echo 'unwrap_me')))".to_string();
|
||||
let output = "('one' 'unwrap_me')";
|
||||
let test_external_func: Function = Function{
|
||||
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)
|
||||
}
|
||||
)
|
||||
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))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(test_external_func))) {
|
||||
print!("Error declaring external func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
|
|
@ -146,28 +140,25 @@ mod eval_tests {
|
|||
Err(e) => {
|
||||
println!("Lexing error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
}
|
||||
|
||||
Ok(initial_ast) => {
|
||||
match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
},
|
||||
Ok(initial_ast) => match eval(initial_ast.clone(), vt.clone(), ft.clone(), false) {
|
||||
Err(e) => {
|
||||
println!("Evaluation error: {}\n", e);
|
||||
assert!(false)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
mod func_tests {
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
use relish::ast::{Ast, Type, Ctr, new_ast};
|
||||
use relish::ast::VTable;
|
||||
use relish::ast::{Function, Operation, FTable, Args, func_declare, func_call, ExternalOperation, lex};
|
||||
use relish::ast::{
|
||||
func_call, func_declare, lex, Args, ExternalOperation, FTable, Function, Operation,
|
||||
};
|
||||
use relish::ast::{new_ast, Ast, Ctr, Type};
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn decl_and_call_internal_func() {
|
||||
let test_internal_func: Function = Function{
|
||||
name: String::from("test_func_in"),
|
||||
let test_internal_func: Function = Function {
|
||||
name: String::from("test_func_in"),
|
||||
loose_syms: false,
|
||||
eval_lazy: false,
|
||||
args: Args::Strict(vec![Type::Bool]),
|
||||
|
|
@ -21,14 +23,13 @@ mod func_tests {
|
|||
}
|
||||
|
||||
Ctr::Bool(is_bool)
|
||||
}
|
||||
))
|
||||
},
|
||||
)),
|
||||
};
|
||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let args = new_ast(Ctr::Bool(true), Ctr::None);
|
||||
if let Some(s) = func_declare(ft.clone(),
|
||||
Rc::new(RefCell::new(test_internal_func))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(test_internal_func))) {
|
||||
print!("Error declaring internal func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
|
|
@ -61,23 +62,21 @@ mod func_tests {
|
|||
match lex("((input))".to_string()) {
|
||||
Err(e) => panic!("{}", e),
|
||||
Ok(finner) => {
|
||||
let test_external_func: Function = Function{
|
||||
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: finner
|
||||
}
|
||||
)
|
||||
function: Operation::External(ExternalOperation {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
};
|
||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let args = new_ast(Ctr::String("test".to_string()), Ctr::None);
|
||||
if let Some(s) = func_declare(ft.clone(),
|
||||
Rc::new(RefCell::new(test_external_func))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(test_external_func)))
|
||||
{
|
||||
print!("Error declaring external func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
|
|
@ -92,13 +91,11 @@ mod func_tests {
|
|||
}
|
||||
|
||||
match func_call(func, args, vt, ft) {
|
||||
Ok(ret) => {
|
||||
match ret {
|
||||
Ctr::String(b) => assert!(b == "test"),
|
||||
_ => {
|
||||
print!("Invalid return from func. Got {:?}\n", ret);
|
||||
assert!(false);
|
||||
}
|
||||
Ok(ret) => match ret {
|
||||
Ctr::String(b) => assert!(b == "test"),
|
||||
_ => {
|
||||
print!("Invalid return from func. Got {:?}\n", ret);
|
||||
assert!(false);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
|
@ -115,23 +112,21 @@ mod func_tests {
|
|||
match lex("((input) (input))".to_string()) {
|
||||
Err(e) => panic!("{}", e),
|
||||
Ok(finner) => {
|
||||
let test_external_func: Function = Function{
|
||||
let test_external_func: Function = Function {
|
||||
name: String::from("echo_2"),
|
||||
loose_syms: false,
|
||||
eval_lazy: false,
|
||||
args: Args::Lazy(1),
|
||||
function: Operation::External(
|
||||
ExternalOperation{
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner
|
||||
}
|
||||
)
|
||||
function: Operation::External(ExternalOperation {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
};
|
||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let args = new_ast(Ctr::String("test".to_string()), Ctr::None);
|
||||
if let Some(s) = func_declare(ft.clone(),
|
||||
Rc::new(RefCell::new(test_external_func))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(test_external_func)))
|
||||
{
|
||||
print!("Error declaring external func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
|
|
@ -146,16 +141,14 @@ mod func_tests {
|
|||
}
|
||||
|
||||
match func_call(func, args, vt, ft) {
|
||||
Ok(ret) => {
|
||||
match ret {
|
||||
Ctr::String(s) => {
|
||||
assert!(s == "test");
|
||||
},
|
||||
_ => {
|
||||
print!("Invalid return from function {:#?}. Should have recieved single string", ret);
|
||||
assert!(false);
|
||||
return
|
||||
}
|
||||
Ok(ret) => match ret {
|
||||
Ctr::String(s) => {
|
||||
assert!(s == "test");
|
||||
}
|
||||
_ => {
|
||||
print!("Invalid return from function {:#?}. Should have recieved single string", ret);
|
||||
assert!(false);
|
||||
return;
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
|
@ -169,7 +162,7 @@ mod func_tests {
|
|||
|
||||
#[test]
|
||||
fn decl_and_call_func_with_nested_call() {
|
||||
let inner_func: Function = Function{
|
||||
let inner_func: Function = Function {
|
||||
name: String::from("test_inner"),
|
||||
loose_syms: false,
|
||||
eval_lazy: false,
|
||||
|
|
@ -186,37 +179,33 @@ mod func_tests {
|
|||
} else {
|
||||
Ctr::None
|
||||
}
|
||||
}
|
||||
))
|
||||
},
|
||||
)),
|
||||
};
|
||||
|
||||
match lex("((test_inner true))".to_string()) {
|
||||
Err(e) => panic!("{}", e),
|
||||
Ok(finner) => {
|
||||
let outer_func: Function = Function{
|
||||
let outer_func: Function = Function {
|
||||
name: String::from("test_outer"),
|
||||
loose_syms: false,
|
||||
eval_lazy: false,
|
||||
args: Args::Lazy(1),
|
||||
function: Operation::External(
|
||||
ExternalOperation{
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner
|
||||
}
|
||||
)
|
||||
function: Operation::External(ExternalOperation {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
};
|
||||
|
||||
let ft = Rc::new(RefCell::new(FTable::new()));
|
||||
let vt = Rc::new(RefCell::new(VTable::new()));
|
||||
let args = new_ast(Ctr::Bool(true), Ctr::None);
|
||||
|
||||
if let Some(s) = func_declare(ft.clone(),
|
||||
Rc::new(RefCell::new(inner_func))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(inner_func))) {
|
||||
print!("Error declaring inner func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
if let Some(s) = func_declare(ft.clone(),
|
||||
Rc::new(RefCell::new(outer_func))) {
|
||||
if let Some(s) = func_declare(ft.clone(), Rc::new(RefCell::new(outer_func))) {
|
||||
print!("Error declaring outer func: {}", s);
|
||||
assert!(false);
|
||||
}
|
||||
|
|
@ -231,13 +220,11 @@ mod func_tests {
|
|||
}
|
||||
|
||||
match func_call(func, args, vt, ft) {
|
||||
Ok(ret) => {
|
||||
match ret {
|
||||
Ctr::String(b) => assert!(b == "test"),
|
||||
_ => {
|
||||
print!("Invalid return from func. Got {:?}\n", ret);
|
||||
assert!(false);
|
||||
}
|
||||
Ok(ret) => match ret {
|
||||
Ctr::String(b) => assert!(b == "test"),
|
||||
_ => {
|
||||
print!("Invalid return from func. Got {:?}\n", ret);
|
||||
assert!(false);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
mod lex_tests {
|
||||
use relish::ast::{lex, ast_to_string};
|
||||
use relish::ast::{ast_to_string, lex};
|
||||
|
||||
#[test]
|
||||
fn test_lex_basic_pair() {
|
||||
|
|
@ -7,7 +7,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), document);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -21,7 +21,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), document);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -35,7 +35,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), document);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -51,7 +51,7 @@ mod lex_tests {
|
|||
Ok(tree) => {
|
||||
print!("Bad token yielded: {}\n", ast_to_string(tree));
|
||||
assert!(false);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
assert_eq!(s, output.to_string());
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), document);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -78,7 +78,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), document);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -94,7 +94,7 @@ mod lex_tests {
|
|||
Ok(tree) => {
|
||||
print!("Bad token yielded: {}\n", ast_to_string(tree));
|
||||
assert!(false);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
assert_eq!(s, output.to_string());
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ mod lex_tests {
|
|||
Ok(tree) => {
|
||||
print!("Bad token yielded: {}\n", ast_to_string(tree));
|
||||
assert!(false);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
assert_eq!(s, output.to_string());
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), output.to_string());
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -138,7 +138,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), output.to_string());
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -153,7 +153,7 @@ mod lex_tests {
|
|||
match lex(document.to_string()) {
|
||||
Ok(tree) => {
|
||||
assert_eq!(ast_to_string(tree), output.to_string());
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
|
|
@ -169,7 +169,7 @@ mod lex_tests {
|
|||
Ok(tree) => {
|
||||
print!("Bad token yielded: {}\n", ast_to_string(tree));
|
||||
assert!(false);
|
||||
},
|
||||
}
|
||||
Err(s) => {
|
||||
assert_eq!(s, output.to_string());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
mod append_lib_tests {
|
||||
use relish::stdlib::{get_stdlib};
|
||||
use relish::ast::{lex, eval, ast_to_string, VTable, FTable, Ctr};
|
||||
use std::rc::Rc;
|
||||
use relish::ast::{ast_to_string, eval, lex, Ctr, FTable, VTable};
|
||||
use relish::stdlib::get_stdlib;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn test_append_to_empty_list() {
|
||||
|
|
@ -23,28 +23,24 @@ mod append_lib_tests {
|
|||
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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => 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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,28 +63,24 @@ mod append_lib_tests {
|
|||
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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => 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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,28 +103,24 @@ mod append_lib_tests {
|
|||
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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => 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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -155,28 +143,24 @@ mod append_lib_tests {
|
|||
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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => 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(_) => assert!(false),
|
||||
Ctr::Integer(_) => assert!(false),
|
||||
Ctr::Float(_) => assert!(false),
|
||||
Ctr::Bool(_) => assert!(false),
|
||||
Ctr::Seg(s) => assert_eq!(ast_to_string(s), result),
|
||||
Ctr::None => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
mod str_lib_tests {
|
||||
use relish::stdlib::{get_stdlib};
|
||||
use relish::ast::{lex, eval, VTable, FTable, Ctr};
|
||||
use std::rc::Rc;
|
||||
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() {
|
||||
|
|
@ -23,28 +23,24 @@ mod str_lib_tests {
|
|||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -67,28 +63,24 @@ mod str_lib_tests {
|
|||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -111,28 +103,24 @@ mod str_lib_tests {
|
|||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
mod var_lib_tests {
|
||||
use relish::stdlib::{get_stdlib};
|
||||
use relish::ast::{lex, eval, VTable, FTable, Ctr};
|
||||
use std::rc::Rc;
|
||||
use relish::ast::{eval, lex, Ctr, FTable, VTable};
|
||||
use relish::stdlib::get_stdlib;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn test_variable_export_and_lookup() {
|
||||
|
|
@ -24,47 +24,41 @@ mod var_lib_tests {
|
|||
Err(s) => {
|
||||
println!("Couldnt lex {}: {}", doc1, s);
|
||||
assert!(false);
|
||||
},
|
||||
}
|
||||
|
||||
Ok(tree) => {
|
||||
match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}", doc2, s);
|
||||
assert!(false);
|
||||
},
|
||||
Ok(tree) => match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}", doc2, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(ctr) => {
|
||||
println!("{:#?}", vt);
|
||||
match ctr {
|
||||
Ctr::None => assert!(true),
|
||||
_ => assert!(false)
|
||||
}
|
||||
Ok(ctr) => {
|
||||
println!("{:#?}", vt);
|
||||
match ctr {
|
||||
Ctr::None => assert!(true),
|
||||
_ => assert!(false),
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
match lex(doc2.to_string()) {
|
||||
Err(s) => {
|
||||
println!("Couldnt lex {}: {}", doc2, s);
|
||||
assert!(false);
|
||||
},
|
||||
|
||||
Ok(tree) => {
|
||||
match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}", doc2, s);
|
||||
assert!(false);
|
||||
},
|
||||
|
||||
Ok(ctr) => {
|
||||
match ctr {
|
||||
Ctr::String(s) => assert_eq!(s, result),
|
||||
_ => assert!(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(tree) => match eval(tree, vt.clone(), ft.clone(), false) {
|
||||
Err(s) => {
|
||||
println!("Couldnt eval {}: {}", doc2, s);
|
||||
assert!(false);
|
||||
}
|
||||
|
||||
Ok(ctr) => match ctr {
|
||||
Ctr::String(s) => assert_eq!(s, result),
|
||||
_ => assert!(false),
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue