- added more unit tests for lexer
- corrected defects revealed by added tests
This commit is contained in:
parent
e4f2fbaa70
commit
172aa4ea4b
3 changed files with 113 additions and 77 deletions
|
|
@ -2,13 +2,47 @@ mod lex_tests {
|
|||
use relish::ast::{lex};
|
||||
|
||||
#[test]
|
||||
fn test_lex_basic_list() {
|
||||
let document: &str = "(hello \"world\")";
|
||||
fn test_lex_basic_pair() {
|
||||
let document: &str = "(hello 'world')";
|
||||
let output: &str = "(hello 'world' nil)";
|
||||
match lex(document.to_string()) {
|
||||
Ok(box_cell) => {
|
||||
assert_eq!(format!("{}", *box_cell), document.to_string());
|
||||
assert_eq!(format!("{}", *box_cell), output.to_string());
|
||||
},
|
||||
Err(_s) => assert!(false)
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lex_basic_list() {
|
||||
let document: &str = "(hello 'world' 1 2 3)";
|
||||
let output: &str = "(hello 'world' 1 2 3 nil)";
|
||||
match lex(document.to_string()) {
|
||||
Ok(box_cell) => {
|
||||
assert_eq!(format!("{}", *box_cell), output.to_string());
|
||||
},
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lex_complex_list() {
|
||||
let document: &str = "(hello 'world' (1 2 (1 2 3)) 1 2 3)";
|
||||
let output: &str = "(hello 'world' (1 2 (1 2 3 nil) nil) 1 2 3 nil)";
|
||||
match lex(document.to_string()) {
|
||||
Ok(box_cell) => {
|
||||
assert_eq!(format!("{}", *box_cell), output.to_string());
|
||||
},
|
||||
Err(s) => {
|
||||
print!("{}\n", s);
|
||||
assert!(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue