add str concat, refactor str tests
This commit is contained in:
parent
e139756a81
commit
ff5e76ff98
2 changed files with 37 additions and 183 deletions
32
src/str.rs
32
src/str.rs
|
|
@ -43,11 +43,41 @@ pub fn get_echo() -> Function {
|
|||
Ctr::Seg(c) => string.push_str(ast_as_string(c.clone(), true).as_str()),
|
||||
Ctr::None => ()
|
||||
}
|
||||
string.push_str("\n");
|
||||
println!(string)
|
||||
return true;
|
||||
}) {
|
||||
eprintln!("circuit loop in echo should not have returned false")
|
||||
}
|
||||
return Ctr::None;
|
||||
}
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_concat() -> Function {
|
||||
return Function{
|
||||
name: String::from("concat"),
|
||||
loose_syms: false,
|
||||
eval_lazy: false,
|
||||
args: Args::Lazy(-1),
|
||||
function: Operation::Internal(
|
||||
|a: Ast, _b: Rc<RefCell<VTable>>, _c: Rc<RefCell<FTable>>| -> Ctr {
|
||||
let mut string = String::from("");
|
||||
if !circuit(a, &mut |arg: &Ctr| {
|
||||
match arg {
|
||||
// should be a thing here
|
||||
Ctr::Symbol(_) => return false,
|
||||
Ctr::String(s) => string.push_str(&s),
|
||||
Ctr::Integer(i) => string.push_str(&i.to_string()),
|
||||
Ctr::Float(f) => string.push_str(&f.to_string()),
|
||||
Ctr::Bool(b) => string.push_str(&b.to_string()),
|
||||
Ctr::Seg(c) => string.push_str(ast_as_string(c.clone(), true).as_str()),
|
||||
Ctr::None => ()
|
||||
}
|
||||
return true;
|
||||
}) {
|
||||
eprintln!("circuit loop in concat should not have returned false")
|
||||
}
|
||||
return Ctr::String(string);
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue