Esempio n. 1
0
    def test_operators(self):
        token = rule_parser.Token("minimum", 1, 20)
        assert token.type == rule_parser.TokenTypes.MINIMUM
        token = rule_parser.Token("and", 1, 20)
        assert token.type == rule_parser.TokenTypes.AND
        token = rule_parser.Token("or", 1, 20)
        assert token.type == rule_parser.TokenTypes.OR
        token = rule_parser.Token("not", 1, 20)
        assert token.type == rule_parser.TokenTypes.NOT

        # as a bonus, test the type converts to strings nicely for debugging
        assert str(token.type) == "not"
Esempio n. 2
0
 def test_numeric(self):
     token = rule_parser.Token("12", 1, 6)
     assert token.value == 12
     assert token.position == 6 - len("12")
     assert repr(token) == ("12")
     with self.assertRaises(AttributeError):
         # if it isn't an error, print it out for debugging
         print(token.identifier)
Esempio n. 3
0
 def test_alpha(self):
     token = rule_parser.Token("abc", 1, 7)
     assert token.identifier == "abc"
     assert token.position == 7 - len(token.identifier)
     assert repr(token) == "'abc'"
     with self.assertRaises(AttributeError):
         # if it isn't an error, print it out for debugging
         print(token.value)