def test_gettoken_x_enclosed(self): from arithmetic import Lexer lexer = Lexer( '5x3' ) lexer.gettoken() lexer.gettoken() self.assertEqual( lexer.value, 'x' ) self.assertEqual( lexer.type, 'x' )
def test_gettoken_plus(self): from arithmetic import Lexer lexer = Lexer( ' + ' ) lexer.gettoken() self.assertEqual( lexer.value, '+' ) self.assertEqual( lexer.type, 'o' )
def test_gettoken_n(self): from arithmetic import Lexer lexer = Lexer( ' name ' ) lexer.gettoken() self.assertEqual( lexer.value, 'name' ) self.assertEqual( lexer.type, 'n' )
def test_gettoken_null_text(self): from arithmetic import Lexer lexer = Lexer( '' ) lexer.gettoken() self.assertEqual( lexer.value, None ) self.assertEqual( lexer.type, '' )
def test_gettoken_invalid(self): from arithmetic import Lexer lexer = Lexer( ' @ ' ) lexer.gettoken() self.assertEqual( lexer.value, '@***' ) self.assertEqual( lexer.type, 'u' )
def test_gettoken_newline(self): from arithmetic import Lexer lexer = Lexer( ' \n ' ) lexer.gettoken() self.assertEqual( lexer.value, '\n' ) self.assertEqual( lexer.type, 'r' )