示例#1
0
class TestRegExpGrammars(unittest.TestCase):
    """Regular expression method tests"""
    def setUp(self):
        from pydsl.Grammar.Tool.Regular import RegularExpressionGrammarTools
        self.g1 = RegularExpressionGrammarTools("(?P<tone>1)23")

    def testCheck(self):
        self.assertTrue(self.g1.check("123"))

    def testBadCheck(self):
        self.assertFalse(self.g1.check("124"))

    def testAlphabet(self):
        self.assertTrue(self.g1.alphabet() == {'1','2','3'}) 

    def testEnumerate(self):
        pass

    def testAskGroup(self):
        result = self.g1.get_groups("123", "tone")
        self.assertTrue((0,1) in result)

    def testGroup(self):
        result = self.g1.groups()
        self.assertTrue(result == ["tone"])
示例#2
0
 def setUp(self):
     from pydsl.Grammar.Tool.Regular import RegularExpressionGrammarTools
     self.g1 = RegularExpressionGrammarTools("(?P<tone>1)23")