"""
------------------------------------------------------------------------------
--                                                                          --
--                              CLASS PROJECT                               --
--                                                                          --
--                         C A L C T E S T S . P Y                          --
--                                                                          --
------------------------------------------------------------------------------
-- <Your Name Here>                                                         --
--                                                                          --
-- <Class Name Here>                                                        --
--                                                                          --
------------------------------------------------------------------------------
-- This file contains the functionality for the calculator project.         --
--                                                                          --
------------------------------------------------------------------------------
"""

from calcfunc import *
# NOTE:  When you finally implement your own string processing functions, you
# should delete the following line!
from tokenizer import *
import unittest

def collect_symbols(expr):
    line = [expr, 0]
    sym =  next_symbol(line)
    collected = ''

    while sym != 'End':
        collected += sym
        sym = next_symbol(line)

    return collected

class TestCalculator(unittest.TestCase):
    def test_next_symbol(self):
        self.assertEqual(collect_symbols(''), '')
        self.assertEqual(collect_symbols('( ) * / ^ + - 99 66.6'), '()*/^+-9966.6')
        self.assertEqual(collect_symbols('9.9.9.9.9'), 'ErrorErrorError.9')
        self.assertEqual(collect_symbols('a%$@#C'), 'Error' * 6)

    def test_look_ahead(self):
        line = ['()99 10.2*+-^', 0]

        self.assertEqual(look_ahead(['', 0], 0), 'Error')
        self.assertEqual(look_ahead(['', 0], 1), 'End')

        self.assertEqual(look_ahead(line, -1), 'Error')
        self.assertEqual(look_ahead(line, 1), '(')
        self.assertEqual(look_ahead(line, 5), '*')
        self.assertEqual(look_ahead(line, 8), '^')
        self.assertEqual(look_ahead(line, 9), 'End')
        self.assertEqual(look_ahead(line, 999), 'End')

if __name__ == '__main__':
    unittest.main()
