def test_evaluate_define(self): output = evaluate( parse( tokenize('(define ((sum (lambda (x y) (+ x y)))) (sum 4 4))'))) print(object) self.assertEqual(output, 2)
def test_evaluate_equals(self): self.assertEqual(evaluate(parse(tokenize('(= 2 (+ 1 1))'))), True)
def test_evaluate_not_equals(self): self.assertEqual(evaluate(parse(tokenize('(!= 5 (+ 2 2))'))), True)
def test_evaluate_composite(self): self.assertEqual( evaluate(parse(tokenize('(* 2 (- (+ (div 4 2) 2) 2))'))), 4)
def test_evaluate_division(self): self.assertEqual(evaluate(parse(tokenize('(div 4 2)'))), 2)
def test_evaluate_multiplication(self): self.assertEqual(evaluate(parse(tokenize('(* 3 3)'))), 9)
def test_evaluate_substraction(self): self.assertEqual(evaluate(parse(tokenize('(- 4 3)'))), 1)
def test_evaluate_sum(self): self.assertEqual(evaluate(parse(tokenize('(+ (+ 1 2 3)(+ 1 2 3))'))), 12)