def test_extra_whitespace_still_ignored(self): program = """ ( + 1 3)""" outcome = htokenize(program) expected = ['(', '+', '1', '3', ')'] self.assertEqual(outcome, expected)
def test_with_overlap(self): program = "(define constant 3)" # contains 'cons', like the builtin outcome = htokenize(program) expected = ['(', 'define', 'constant', '3', ')'] self.assertEqual(outcome, expected)
def test_with_nested_brackets(self): program = "(+ 1 (/ 9 3))" outcome = htokenize(program) expected = ['(', '+', '1', '(', '/', '9', '3', ')', ')'] self.assertEqual(outcome, expected)
def test_with_text_atoms(self): program = "(define abc 12)" outcome = htokenize(program) expected = ['(', 'define', 'abc', '12', ')']
def test_evaluate_simple_expression(self): program = "(+ 1 2)" outcome = htokenize(program) self.assertEqual(outcome, ['(', '+', '1', '2', ')'])