elementary shell behavior: can kick off a foreground process and
handle signals
This commit is contained in:
parent
3b1ae0efd5
commit
99cb9e5a2e
17 changed files with 619 additions and 167 deletions
103
tests/test_lib_posix.rs
Normal file
103
tests/test_lib_posix.rs
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
mod posix_tests {
|
||||
use relish::aux::args_from_ast;
|
||||
use relish::stdlib::{dynamic_stdlib, static_stdlib};
|
||||
use relish::ast::{lex, eval, SymTable};
|
||||
|
||||
#[test]
|
||||
fn test_cmd_singlet() {
|
||||
let document = "(binary)";
|
||||
let result = vec!["binary"];
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms, None).unwrap();
|
||||
|
||||
if let Ok(ref s) = lex(&document.to_string()) {
|
||||
assert_eq!(
|
||||
args_from_ast(s, &mut syms),
|
||||
result
|
||||
)
|
||||
} else {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cmd_list() {
|
||||
let document = "(binary --flag=1 122 'yeet' true)";
|
||||
let result = vec!["binary", "--flag=1", "122", "yeet", "true"];
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms, None).unwrap();
|
||||
|
||||
if let Ok(ref s) = lex(&document.to_string()) {
|
||||
assert_eq!(
|
||||
args_from_ast(s, &mut syms),
|
||||
result
|
||||
)
|
||||
} else {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cmd_syms_undef() {
|
||||
let document = "(binary --flag=1 122 'yeet' true syms)";
|
||||
let result = vec!["binary", "--flag=1", "122", "yeet", "true", "syms"];
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms, None).unwrap();
|
||||
|
||||
if let Ok(ref s) = lex(&document.to_string()) {
|
||||
assert_eq!(
|
||||
args_from_ast(s, &mut syms),
|
||||
result
|
||||
)
|
||||
} else {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cmd_syms_unwrap_simple() {
|
||||
let decl = "(def syms '' 1)";
|
||||
let document = "(binary --flag=1 122 'yeet' true syms)";
|
||||
let result = vec!["binary", "--flag=1", "122", "yeet", "true", "1"];
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms, None).unwrap();
|
||||
|
||||
eval(&lex(&decl.to_string()).unwrap(), &mut syms).unwrap();
|
||||
|
||||
if let Ok(ref s) = lex(&document.to_string()) {
|
||||
assert_eq!(
|
||||
args_from_ast(s, &mut syms),
|
||||
result
|
||||
)
|
||||
} else {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cmd_syms_unwrap_eval() {
|
||||
let document = "(binary --flag=1 122 'yeet' true (add 1 2))";
|
||||
let result = vec!["binary", "--flag=1", "122", "yeet", "true", "3"];
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms, None).unwrap();
|
||||
|
||||
if let Ok(ref s) = lex(&document.to_string()) {
|
||||
assert_eq!(
|
||||
args_from_ast(s, &mut syms),
|
||||
result
|
||||
)
|
||||
} else {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue