def test_IDENTIFIER(self): t = tuple((i.type, i.value) for i in lex('world*')) self.assertEqual(t, ( ("IDENTIFIER", "world*"), ))
def test_error(self): self.assertRaises(SyntaxError, lambda: tuple(lex("\"hello")))
def test_DIGITS(self): t = tuple((i.type, i.value) for i in lex('12')) self.assertEqual(t, ( ("DIGITS", "12"), ))
def test_SEMICOLON(self): t = tuple((i.type, i.value) for i in lex(";;;")) self.assertEqual(t, ())
def test_QUOTE(self): t = tuple((i.type, i.value) for i in lex("'''")) self.assertEqual(t, ( ("QUOTE", "'"), ("QUOTE", "'"), ("QUOTE", "'")))
def test_RPAREN(self): t = tuple((i.type, i.value) for i in lex(")))")) self.assertEqual(t, ( ("RPAREN", ")"), ("RPAREN", ")"), ("RPAREN", ")")))
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)