diff options
author | Dominick Allen <dominick.allen1989@gmail.com> | 2020-06-26 21:12:16 -0500 |
---|---|---|
committer | Dominick Allen <dominick.allen1989@gmail.com> | 2020-06-26 21:12:16 -0500 |
commit | ad9f7e6a689c7fe42444cbe22ecdf1de8d092d5b (patch) | |
tree | f387be46e818cdfafeae36c69a94d09ed1da26f9 /src/lib/types.rs | |
parent | 36e1bf722a3d366cea20ab7315d63d588d23dc48 (diff) |
Evaluate basic arithmetic.
Diffstat (limited to 'src/lib/types.rs')
-rw-r--r-- | src/lib/types.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/lib/types.rs b/src/lib/types.rs index 4c2900a..7755c04 100644 --- a/src/lib/types.rs +++ b/src/lib/types.rs @@ -51,47 +51,4 @@ pub enum Type { Operator(Op), } -#[derive(PartialEq, Debug)] -pub enum SEXP { - Atom(Type), - Sexpr(Vec<SEXP>) -} - -#[test] -fn construct() { - let atom1 = SEXP::Atom(Type::Number(Number::Int(1))); - let atom2 = SEXP::Atom(Type::Number(Number::Int(2))); - let atom3 = SEXP::Atom(Type::Number(Number::Int(3))); - let atom4 = SEXP::Atom(Type::Number(Number::Int(4))); - let sexp = SEXP::Sexpr(vec!(atom1, atom2, atom3, atom4)); - match sexp { - SEXP::Sexpr(ref x) => { - assert_eq!(x[0], SEXP::Atom(Type::Number(Number::Int(1)))); - }, - _ => panic!("What") - } -} - -#[test] -fn mutability() { - let atom1 = SEXP::Atom(Type::Number(Number::Int(1))); - let atom2 = SEXP::Atom(Type::Number(Number::Int(2))); - let atom3 = SEXP::Atom(Type::Number(Number::Int(3))); - let atom4 = SEXP::Atom(Type::Number(Number::Int(4))); - let mut sexp = SEXP::Sexpr(vec!(atom1, atom2, atom3, atom4)); - match sexp { - SEXP::Sexpr(ref mut x) => match x[0] { - SEXP::Atom(Type::Number(Number::Int(ref mut x))) => *x += 7, - _ => panic!("What") - }, - _ => panic!("What") - } - - match sexp { - SEXP::Sexpr(ref x) => { - assert_eq!(x[0], SEXP::Atom(Type::Number(Number::Int(8)))); - }, - _ => panic!("What") - } -} |