Exemple #1
0
 def test_extra_whitespace_still_ignored(self):
     program = """   (   + 1
                             3)"""
     outcome = htokenize(program)
     expected = ['(', '+', '1', '3', ')']
     self.assertEqual(outcome, expected)
Exemple #2
0
 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)
Exemple #3
0
 def test_with_nested_brackets(self):
     program = "(+ 1 (/ 9 3))"
     outcome = htokenize(program)
     expected = ['(', '+', '1', '(', '/', '9', '3', ')', ')']
     self.assertEqual(outcome, expected)
Exemple #4
0
 def test_with_text_atoms(self):
     program = "(define abc 12)"
     outcome = htokenize(program)
     expected = ['(', 'define', 'abc', '12', ')']
Exemple #5
0
 def test_evaluate_simple_expression(self):
     program = "(+ 1 2)"
     outcome = htokenize(program)
     self.assertEqual(outcome, ['(', '+', '1', '2', ')'])