Example #1
0
 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' )
Example #2
0
 def test_gettoken_plus(self):
     from arithmetic import Lexer
     lexer = Lexer( ' + ' )
     lexer.gettoken()
     self.assertEqual( lexer.value, '+' )
     self.assertEqual( lexer.type, 'o' )
Example #3
0
 def test_gettoken_n(self):
     from arithmetic import Lexer
     lexer = Lexer( ' name ' )
     lexer.gettoken()
     self.assertEqual( lexer.value, 'name' )
     self.assertEqual( lexer.type, 'n' )
Example #4
0
 def test_gettoken_null_text(self):
     from arithmetic import Lexer
     lexer = Lexer( '' )
     lexer.gettoken()
     self.assertEqual( lexer.value, None )
     self.assertEqual( lexer.type, '' )
Example #5
0
 def test_gettoken_invalid(self):
     from arithmetic import Lexer
     lexer = Lexer( ' @ ' )
     lexer.gettoken()
     self.assertEqual( lexer.value, '@***' )
     self.assertEqual( lexer.type, 'u' )
Example #6
0
 def test_gettoken_newline(self):
     from arithmetic import Lexer
     lexer = Lexer( ' \n ' )
     lexer.gettoken()
     self.assertEqual( lexer.value, '\n' )
     self.assertEqual( lexer.type, 'r' )