mod append_lib_tests { use relish::ast::{eval, lex, SymTable}; use relish::stdlib::{dynamic_stdlib, static_stdlib}; #[test] fn test_append_to_empty_list() { let document = "(append () 1)"; let result = "(1)"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); dynamic_stdlib(&mut syms).unwrap(); assert_eq!( *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(), result.to_string(), ); } #[test] fn test_multi_append_to_empty_list() { let document = "(append () 1 'two' 3.4)"; let result = "(1 'two' 3.4)"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); dynamic_stdlib(&mut syms).unwrap(); assert_eq!( *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(), result.to_string(), ); } #[test] fn test_append_to_full_list() { let document = "(append (1 2) 3)"; let result = "(1 2 3)"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); dynamic_stdlib(&mut syms).unwrap(); assert_eq!( *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(), result.to_string(), ); } #[test] fn test_mono_append() { let document = "(append)"; let result = "()"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); dynamic_stdlib(&mut syms).unwrap(); assert_eq!( *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(), result.to_string(), ); } #[test] fn test_append_no_list() { let document = "(append 'test' 1 2 3)"; let result = "('test' 1 2 3)"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); dynamic_stdlib(&mut syms).unwrap(); assert_eq!( *eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(), result.to_string(), ); } }