another tweak to eval/quote equivalency, more tests
This commit is contained in:
parent
33791c7f3b
commit
0a01f9178c
3 changed files with 42 additions and 57 deletions
|
|
@ -92,9 +92,11 @@ mod decl_lib_tests {
|
|||
fn test_variable_def_redef_via_reference_and_lookup() {
|
||||
let doc1 = "(def test 'my test var' 1)";
|
||||
let doc2 = "(def ref 'references test' (quote test))";
|
||||
let doc3 = "(def (eval ref) 'my test var' '2')";
|
||||
let doc4 = "(test)";
|
||||
let result = "('2')";
|
||||
let doc3 = "(def ref 'my test var' '2')";
|
||||
let test = "(test)";
|
||||
let res1 = "(1)";
|
||||
let doc4 = "(def (eval ref) 'my test var' '2')";
|
||||
let res2 = "('2')";
|
||||
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms);
|
||||
|
|
@ -103,8 +105,12 @@ mod decl_lib_tests {
|
|||
eval(&lex(&doc1.to_string()).unwrap(), &mut syms).unwrap();
|
||||
eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
|
||||
eval(&lex(&doc3.to_string()).unwrap(), &mut syms).unwrap();
|
||||
let res = *eval(&lex(&doc4.to_string()).unwrap(), &mut syms).unwrap();
|
||||
assert_eq!(res.to_string(), result);
|
||||
let r1 = *eval(&lex(&test.to_string()).unwrap(), &mut syms).unwrap();
|
||||
assert_eq!(r1.to_string(), res1);
|
||||
eval(&lex(&doc2.to_string()).unwrap(), &mut syms).unwrap();
|
||||
eval(&lex(&doc4.to_string()).unwrap(), &mut syms).unwrap();
|
||||
let r2 = *eval(&lex(&test.to_string()).unwrap(), &mut syms).unwrap();
|
||||
assert_eq!(r2.to_string(), res2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -235,27 +241,6 @@ mod decl_lib_tests {
|
|||
);
|
||||
}
|
||||
|
||||
/* THIS TEST REMOVED BECAUSE EVAL SHOULDNT ARBITRARILY DO THINGS TWICE
|
||||
* KEPT FOR REFERENCE PURPOSES JUST IN CASE.
|
||||
#[test]
|
||||
fn test_eval_var_deref() {
|
||||
let def1 = "(def one '' 1)";
|
||||
let def2 = "(def two '' (quote one))";
|
||||
let document = "(eval two)";
|
||||
let result = "1";
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms).unwrap();
|
||||
dynamic_stdlib(&mut syms).unwrap();
|
||||
eval(&lex(&def1.to_string()).unwrap(), &mut syms).unwrap();
|
||||
eval(&lex(&def2.to_string()).unwrap(), &mut syms).unwrap();
|
||||
assert_eq!(
|
||||
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
|
||||
.unwrap()
|
||||
.to_string(),
|
||||
result.to_string(),
|
||||
);
|
||||
}*/
|
||||
|
||||
#[test]
|
||||
fn test_lambda_str_equivalency_list() {
|
||||
let document = "(lambda (x y) (add x y))";
|
||||
|
|
@ -375,4 +360,15 @@ mod decl_lib_tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_eval_quote() {
|
||||
let doc = "(eval (quote (add 1 1)))";
|
||||
let mut syms = SymTable::new();
|
||||
static_stdlib(&mut syms);
|
||||
dynamic_stdlib(&mut syms, None);
|
||||
assert_eq!(
|
||||
*eval(&lex(&doc.to_string()).unwrap(), &mut syms).unwrap().to_string(),
|
||||
2.to_string()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue