예제 #1
0
 def testConsumeLineEnding(self):
     lex = Lexer("\nhello")
     lex._consume()  # consume the newline
     self.assertEqual(lex.lineNum, 2)  # line has increased
     self.assertEqual(lex.charNum, 1)  # charNum as been reset
     self.assertEqual(lex.p, 1)  # p has advanced
     self.assertEqual(lex.c, 'h')  # c is the next character
예제 #2
0
 def testConsumeNoCharactersLeft(self):
     lex = Lexer('h')
     lex._consume()  # consume the 'h'
     self.assertEqual(lex.charNum, 2)  # charNum has increased
     self.assertEqual(lex.p, 1)  # p has advanced
     self.assertEqual(lex.c, TokenTypes.EOF)
예제 #3
0
 def testConsumeNormal(self):
     lex = Lexer('hello')
     lex._consume()  # consume the 'h'
     self.assertEqual(lex.charNum, 2)  # charNum has increased
     self.assertEqual(lex.p, 1)  # p has advanced
     self.assertEqual(lex.c, 'e')  # c is the next character