Esempio n. 1
0
 def testExpUnOpHash(self):
     p = get_parser('#foo')
     node = p._exp()
     self.assertIsNotNone(node)
     self.assertTrue(isinstance(node, parser.ExpUnOp))
     self.assertEqual('#', node.unop.value)
     self.assertTrue(isinstance(node.exp.value, parser.VarName))
     self.assertEqual(lexer.TokName('foo'), node.exp.value.name)
Esempio n. 2
0
 def testValidLuaNoErrors(self):
     lxr = lexer.Lexer(version=4)
     for line in VALID_LUA.split(b'\n'):
         lxr._process_line(line)
     tokens = lxr.tokens
     self.assertEqual(lexer.TokName(b'v1'), tokens[0])
     self.assertEqual(lexer.TokSpace(b' '), tokens[1])
     self.assertEqual(lexer.TokSymbol(b'='), tokens[2])
     self.assertEqual(lexer.TokSpace(b' '), tokens[3])
     self.assertEqual(lexer.TokKeyword(b'nil'), tokens[4])
Esempio n. 3
0
 def testQuestionMarkPrint(self):
     lxr = lexer.Lexer(version=4)
     lxr._process_line(b'?\n')
     self.assertEqual(2, len(lxr._tokens))
     self.assertEqual(lexer.TokName(b'?'), lxr._tokens[0])
Esempio n. 4
0
 def testOneName(self):
     lxr = lexer.Lexer(version=4)
     lxr._process_line(b'android\n')
     self.assertEqual(2, len(lxr._tokens))
     self.assertEqual(lexer.TokName(b'android'), lxr._tokens[0])