rustfmt previous commit

This commit is contained in:
Ava Hahn 2023-03-05 22:21:18 -08:00
parent dc6342bc74
commit ca9f755d50
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
10 changed files with 144 additions and 123 deletions

View file

@ -7,7 +7,7 @@ mod eval_tests {
let test_doc = "(1 2)".to_string();
let mut syms = SymTable::new();
let doc_tree = lex(&test_doc).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
assert_eq!(reduced.to_string(), test_doc);
}
@ -16,9 +16,8 @@ mod eval_tests {
let test_doc = "(1 (1 2 3 4 5) 5)".to_string();
let mut syms = SymTable::new();
let doc_tree = lex(&test_doc).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
assert_eq!(reduced.to_string(), test_doc);
}
#[test]
@ -43,7 +42,7 @@ mod eval_tests {
syms.insert(String::from("echo"), test_external_func);
let doc_tree = lex(&test_doc).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
assert_eq!(reduced.to_string(), output);
}
@ -69,7 +68,7 @@ mod eval_tests {
syms.insert(String::from("echo"), test_external_func);
let doc_tree = lex(&test_doc).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
let reduced = *eval(&doc_tree, &mut syms).unwrap();
assert_eq!(reduced.to_string(), output);
}

View file

@ -25,7 +25,10 @@ mod func_tests {
};
let args = Seg::from(Box::new(Ctr::Bool(true)), Box::new(Ctr::None));
syms.insert(String::from("test_func_in"), test_internal_func);
if let Ctr::Bool(b) = *syms.call_symbol(&"test_func_in".to_string(), &args, true).unwrap() {
if let Ctr::Bool(b) = *syms
.call_symbol(&"test_func_in".to_string(), &args, true)
.unwrap()
{
assert!(b)
}
}
@ -51,7 +54,10 @@ mod func_tests {
);
syms.insert(String::from("test_func_in"), test_external_func);
if let Ctr::Bool(b) = *syms.call_symbol(&"test_func_in".to_string(), &args, true).unwrap() {
if let Ctr::Bool(b) = *syms
.call_symbol(&"test_func_in".to_string(), &args, true)
.unwrap()
{
assert!(b)
}
}
@ -77,10 +83,13 @@ mod func_tests {
);
syms.insert(String::from("echo_2"), test_external_func);
assert_eq!(*syms.call_symbol(&"echo_2".to_string(), &args, true)
.unwrap()
.to_string(),
"'test'".to_string());
assert_eq!(
*syms
.call_symbol(&"echo_2".to_string(), &args, true)
.unwrap()
.to_string(),
"'test'".to_string()
);
}
#[test]
@ -122,10 +131,12 @@ mod func_tests {
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);
assert_eq!(syms.call_symbol(&"test_outer".to_string(), &args, true)
.unwrap()
.to_string(),
"'test'".to_string());
assert_eq!(
syms.call_symbol(&"test_outer".to_string(), &args, true)
.unwrap()
.to_string(),
"'test'".to_string()
);
}
#[test]
@ -241,8 +252,7 @@ mod func_tests {
syms.call_symbol(&"test_func_in".to_string(), &args, true)
.err()
.unwrap(),
"error in call to undefined-symbol: undefined symbol: undefined-symbol"
.to_string(),
"error in call to undefined-symbol: undefined symbol: undefined-symbol".to_string(),
);
}
}

View file

@ -4,86 +4,59 @@ mod lex_tests {
#[test]
fn test_lex_basic_pair() {
let document = String::from("(hello 'world')");
assert_eq!(
lex(&document).unwrap().to_string(),
document
);
assert_eq!(lex(&document).unwrap().to_string(), document);
}
#[test]
fn test_lex_basic_list() {
let document = String::from("(hello 'world' 1 2 3)");
assert_eq!(
lex(&document).unwrap().to_string(),
document
);
assert_eq!(lex(&document).unwrap().to_string(), document);
}
#[test]
fn test_lex_complex_list() {
let document = String::from("(hello 'world' (1 2 (1 2 3)) 1 2 3)");
assert_eq!(
lex(&document).unwrap().to_string(),
document
);
assert_eq!(lex(&document).unwrap().to_string(), document);
}
#[test]
fn test_bad_symbol() {
let document = String::from("(as;dd)");
let output: &str = "Problem lexing document: \"Unparsable token: as;dd\"";
assert_eq!(
lex(&document).err().unwrap(),
output.to_string(),
);
assert_eq!(lex(&document).err().unwrap(), output.to_string(),);
}
#[test]
fn test_list_delim_in_str() {
let document = String::from("('(')");
assert_eq!(
lex(&document).unwrap().to_string(),
document
);
assert_eq!(lex(&document).unwrap().to_string(), document);
}
#[test]
fn test_empty_string() {
let document = String::from("('')");
assert_eq!(
lex(&document).unwrap().to_string(),
document
);
assert_eq!(lex(&document).unwrap().to_string(), document);
}
#[test]
fn test_unmatched_list_delim_flat() {
let document = String::from("(one two");
let output: &str = "Problem lexing document: \"Unmatched list delimiter in input\"";
assert_eq!(
lex(&document).err().unwrap(),
output.to_string(),
);
assert_eq!(lex(&document).err().unwrap(), output.to_string(),);
}
#[test]
fn test_unmatched_list_delim_complex() {
let document = String::from("(one two (three)");
let output: &str = "Problem lexing document: \"Unmatched list delimiter in input\"";
assert_eq!(
lex(&document).err().unwrap(),
output.to_string(),
);
assert_eq!(lex(&document).err().unwrap(), output.to_string(),);
}
#[test]
fn test_comment() {
let document = String::from("#!/bin/relish\n(one two)");
let output: &str = "(one two)";
assert_eq!(
lex(&document).unwrap().to_string(),
output.to_string(),
);
assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),);
}
#[test]
@ -91,30 +64,20 @@ mod lex_tests {
let document =
String::from("#!/bin/relish\n((one two)# another doc comment\n(three four))");
let output: &str = "((one two) (three four))";
assert_eq!(
lex(&document).unwrap().to_string(),
output.to_string(),
);
assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),);
}
#[test]
fn test_inline_comment() {
let document = String::from("#!/bin/relish\n((one two)\n# another doc comment\nthree)");
let output: &str = "((one two) three)";
assert_eq!(
lex(&document).unwrap().to_string(),
output.to_string(),
);
assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),);
}
#[test]
fn test_bad_token_list() {
let document = String::from("(one t(wo)");
let output: &str = "Problem lexing document: \"list started in middle of another token\"";
assert_eq!(
lex(&document).err().unwrap(),
output.to_string(),
);
assert_eq!(lex(&document).err().unwrap(), output.to_string(),);
}
}

View file

@ -11,7 +11,9 @@ mod append_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -26,7 +28,9 @@ mod append_lib_tests {
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -41,7 +45,9 @@ mod append_lib_tests {
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -56,7 +62,9 @@ mod append_lib_tests {
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -71,7 +79,9 @@ mod append_lib_tests {
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}

View file

@ -10,7 +10,9 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -23,7 +25,9 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -36,7 +40,9 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -49,10 +55,11 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
@ -63,10 +70,11 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
#[test]
@ -77,7 +85,9 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -90,7 +100,9 @@ mod bool_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}

View file

@ -10,7 +10,9 @@ mod control_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -23,7 +25,9 @@ mod control_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -35,8 +39,10 @@ mod control_lib_tests {
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(),
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -52,7 +58,9 @@ mod control_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -65,7 +73,9 @@ mod control_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}
@ -83,7 +93,9 @@ mod control_lib_tests {
static_stdlib(&mut syms).unwrap();
dynamic_stdlib(&mut syms).unwrap();
assert_eq!(
*eval(&lex(&document.to_string()).unwrap(), &mut syms).unwrap().to_string(),
*eval(&lex(&document.to_string()).unwrap(), &mut syms)
.unwrap()
.to_string(),
result.to_string(),
);
}