rustfmt
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
ecbc47d4fe
commit
bc09cb07b1
17 changed files with 236 additions and 217 deletions
|
|
@ -1,8 +1,8 @@
|
|||
mod func_tests {
|
||||
use std::rc::Rc;
|
||||
use relish::ast::lex;
|
||||
use relish::ast::{Args, Ctr, Seg, Symbol, ValueType};
|
||||
use relish::ast::{SymTable, Type, UserFn};
|
||||
use relish::ast::{Args, Symbol, Ctr, Seg, ValueType};
|
||||
use std::rc::Rc;
|
||||
|
||||
#[test]
|
||||
fn decl_and_call_internal_func() {
|
||||
|
|
@ -22,10 +22,7 @@ mod func_tests {
|
|||
},
|
||||
)),
|
||||
};
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::Bool(true)),
|
||||
Box::new(Ctr::None)
|
||||
);
|
||||
let args = Seg::from(Box::new(Ctr::Bool(true)), Box::new(Ctr::None));
|
||||
|
||||
syms.insert(String::from("test_func_in"), test_internal_func);
|
||||
|
||||
|
|
@ -53,7 +50,7 @@ mod func_tests {
|
|||
name: String::from("echo"),
|
||||
conditional_branches: false,
|
||||
args: Args::Lazy(1),
|
||||
value: ValueType::FuncForm(UserFn{
|
||||
value: ValueType::FuncForm(UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
|
|
@ -61,7 +58,7 @@ mod func_tests {
|
|||
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::String("test".to_string())),
|
||||
Box::new(Ctr::None)
|
||||
Box::new(Ctr::None),
|
||||
);
|
||||
|
||||
syms.insert(String::from("test_func_in"), test_external_func);
|
||||
|
|
@ -89,11 +86,11 @@ mod func_tests {
|
|||
match lex(&"(input input)".to_string()) {
|
||||
Err(e) => panic!("{}", e),
|
||||
Ok(finner) => {
|
||||
let test_external_func: Symbol = Symbol{
|
||||
let test_external_func: Symbol = Symbol {
|
||||
name: String::from("echo_2"),
|
||||
conditional_branches: false,
|
||||
args: Args::Lazy(1),
|
||||
value: ValueType::FuncForm(UserFn{
|
||||
value: ValueType::FuncForm(UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
|
|
@ -101,7 +98,7 @@ mod func_tests {
|
|||
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::String("test".to_string())),
|
||||
Box::new(Ctr::None)
|
||||
Box::new(Ctr::None),
|
||||
);
|
||||
|
||||
syms.insert(String::from("echo_2"), test_external_func);
|
||||
|
|
@ -147,16 +144,13 @@ mod func_tests {
|
|||
name: String::from("test_outer"),
|
||||
conditional_branches: false,
|
||||
args: Args::Lazy(1),
|
||||
value: ValueType::FuncForm(UserFn{
|
||||
value: ValueType::FuncForm(UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
};
|
||||
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::Bool(true)),
|
||||
Box::new(Ctr::None)
|
||||
);
|
||||
let args = Seg::from(Box::new(Ctr::Bool(true)), Box::new(Ctr::None));
|
||||
|
||||
syms.insert(String::from("test_inner"), inner_func);
|
||||
syms.insert(String::from("test_outer"), outer_func);
|
||||
|
|
@ -196,10 +190,7 @@ mod func_tests {
|
|||
},
|
||||
)),
|
||||
};
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::Integer(1)),
|
||||
Box::new(Ctr::None)
|
||||
);
|
||||
let args = Seg::from(Box::new(Ctr::Integer(1)), Box::new(Ctr::None));
|
||||
|
||||
syms.insert(String::from("test_func_in"), test_internal_func);
|
||||
|
||||
|
|
@ -221,7 +212,7 @@ mod func_tests {
|
|||
name: String::from("echo"),
|
||||
conditional_branches: false,
|
||||
args: Args::Lazy(1),
|
||||
value: ValueType::FuncForm(UserFn{
|
||||
value: ValueType::FuncForm(UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
|
|
@ -229,7 +220,7 @@ mod func_tests {
|
|||
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::String("test".to_string())),
|
||||
Box::new(Ctr::Seg(Seg::from_mono(Box::new(Ctr::Integer(1)))))
|
||||
Box::new(Ctr::Seg(Seg::from_mono(Box::new(Ctr::Integer(1))))),
|
||||
);
|
||||
|
||||
syms.insert(String::from("test_func_in"), test_external_func);
|
||||
|
|
@ -254,7 +245,7 @@ mod func_tests {
|
|||
name: String::from("echo"),
|
||||
conditional_branches: false,
|
||||
args: Args::Lazy(1),
|
||||
value: ValueType::FuncForm(UserFn{
|
||||
value: ValueType::FuncForm(UserFn {
|
||||
arg_syms: vec!["input".to_string()],
|
||||
ast: finner,
|
||||
}),
|
||||
|
|
@ -293,13 +284,16 @@ mod func_tests {
|
|||
};
|
||||
let args = Seg::from(
|
||||
Box::new(Ctr::Symbol("undefined-symbol".to_string())),
|
||||
Box::new(Ctr::None)
|
||||
Box::new(Ctr::None),
|
||||
);
|
||||
|
||||
syms.insert(String::from("test_func_in"), test_internal_func);
|
||||
|
||||
if let Err(s) = syms.call_symbol(&"test_func_in".to_string(), &args, true) {
|
||||
assert_eq!(s, "error in call to undefined-symbol: undefined symbol: undefined-symbol");
|
||||
assert_eq!(
|
||||
s,
|
||||
"error in call to undefined-symbol: undefined symbol: undefined-symbol"
|
||||
);
|
||||
} else {
|
||||
print!("call to function succeeded (shouldnt have)");
|
||||
assert!(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue