示例#1
0
 def test_IDENTIFIER(self):
     t = tuple((i.type, i.value) for i in lex('world*'))
     self.assertEqual(t, (
         ("IDENTIFIER", "world*"), ))
示例#2
0
 def test_error(self):
     self.assertRaises(SyntaxError, lambda: tuple(lex("\"hello")))
示例#3
0
 def test_DIGITS(self):
     t = tuple((i.type, i.value) for i in lex('12'))
     self.assertEqual(t, (
         ("DIGITS", "12"), ))
示例#4
0
 def test_SEMICOLON(self):
     t = tuple((i.type, i.value) for i in lex(";;;"))
     self.assertEqual(t, ())
示例#5
0
 def test_QUOTE(self):
     t = tuple((i.type, i.value) for i in lex("'''"))
     self.assertEqual(t, (
         ("QUOTE", "'"), ("QUOTE", "'"), ("QUOTE", "'")))
示例#6
0
 def test_RPAREN(self):
     t = tuple((i.type, i.value) for i in lex(")))"))
     self.assertEqual(t, (
         ("RPAREN", ")"), ("RPAREN", ")"), ("RPAREN", ")")))
示例#7
0
 def test_lineno(self):
     one, two, three = tuple(lex("1\n2\n3\n"))
     self.assertEqual(one.lineno, 1)
     self.assertEqual(two.lineno, 2)
     self.assertEqual(three.lineno, 3)