[types] Move tests to tests/ directory; implement a bunch of Display tests

This commit is contained in:
Eryn Wells 2018-08-25 09:21:34 -07:00
parent d10c72711b
commit 31081ba5a9
4 changed files with 66 additions and 15 deletions

View file

@ -54,7 +54,7 @@ impl Obj {
impl fmt::Display for Obj {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Obj::Null => write!(f, "null"),
Obj::Null => write!(f, "()"),
Obj::Ptr(obj) => write!(f, "{}", obj)
}
}

View file

@ -14,6 +14,10 @@ pub struct Pair {
}
impl Pair {
pub fn new(car: Obj, cdr: Obj) -> Pair {
Pair { car, cdr }
}
pub fn empty() -> Pair {
Pair { car: Obj::Null, cdr: Obj::Null }
}
@ -52,11 +56,4 @@ impl fmt::Display for Pair {
#[cfg(test)]
mod tests {
use super::Pair;
#[test]
fn display_empty_pair() {
let empty = Pair::empty();
let disp = format!("{}", empty);
assert_eq!(disp, "(())");
}
}

View file

@ -38,13 +38,6 @@ impl fmt::Display for Sym {
mod tests {
use super::Sym;
#[test]
fn syms_display_as_strings() {
let sym = Sym::with_str("abc");
let disp = format!("{}", sym);
assert_eq!(disp, "abc");
}
#[test]
fn syms_with_the_same_name_are_equal() {
let a = Sym::with_str("abc");