Exemplo n.º 1
0
class TestHostPythonGrammars(unittest.TestCase):
    """Python Grammar tool with auxiliary grammars"""
    def setUp(self):
        from pydsl.Grammar.Tool.Python import PythonGrammarTools
        self.g1 = PythonGrammarTools({"matchFun":lambda x,aux: aux["ext"].check(x),"auxdic":{"ext":"email"}})

    def testCheck(self):
        self.assertTrue(self.g1.check("*****@*****.**"))

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

    def testsenumerateWords(self):
        pass

    def testAskGroup(self):
        pass

    def testCheckWordStatus(self):
        pass
    
    def testSerialize(self):
        pass

    def testloadgrammar(self):
        #Load a grammar that uses a package (integerOPGrammar), call check
        from pydsl.Memory.Loader import load_checker # FIXME: is load_grammar_tool
        grammar = load_checker("integerop")
        self.assertTrue(grammar.check("123+3"))
Exemplo n.º 2
0
class TestPythonGrammars(unittest.TestCase):
    """Python Grammar Tool"""
    def setUp(self):
        from pydsl.Grammar.Tool.Python import PythonGrammarTools
        self.g1 = PythonGrammarTools({"matchFun":lambda x:int(str(x))>6})

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

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

    def testsenumerateWords(self):
        pass

    def testAskGroup(self):
        pass

    def testCheckWordStatus(self):
        pass
    
    def testSerialize(self):
        pass

    def testIterate(self):
        pass