Esempio n. 1
0
    def test_dfa_compile2(self):
        from pypy.lang.automata.dfa import getautomaton, convertagain, recognizeparts
        more = [convertagain(getautomaton()), convertagain(getautomaton())]
        def main(gets, gets2):
            alltrans, final_states = more[gets2]
            s = ["aaaaaaaaaab", "aaaa"][gets]
            return recognizeparts(alltrans, final_states, s)

        res = self.timeshift_from_portal(main, recognizeparts, [0, 0], policy=P_NOVIRTUAL)
        assert res

        # XXX unfortunately we have to create a new version each time - because of pbc
        res = self.timeshift_from_portal(main, recognizeparts, [1, 0], policy=P_NOVIRTUAL)
        assert not res
Esempio n. 2
0
    def test_dfa_compile(self):
        from pypy.lang.automata.dfa import getautomaton, convertdfa, recognizetable
        a = getautomaton()
        dfatable, final_states = convertdfa(a)
        def main(gets):
            s = ["aaaaaaaaaab", "aaaa"][gets]
            return recognizetable(dfatable, s, final_states)

        res = self.timeshift_from_portal(main, recognizetable, [0], policy=P_NOVIRTUAL)
        assert res

        res = self.timeshift_from_portal(main, recognizetable, [1], policy=P_NOVIRTUAL)
        assert not res
Esempio n. 3
0
    def test_dfa_compile(self):
        from pypy.lang.automata.dfa import getautomaton, convertdfa, recognizetable
        a = getautomaton()
        dfatable, final_states = convertdfa(a)
        def main(gets):
            s = ["aaaaaaaaaab", "aaaa"][gets]
            return recognizetable(dfatable, s, final_states)

        # must backendoptimize to remove the mallocs related
        # to the interior ptrs
        res = self.timeshift_from_portal(main, recognizetable, [0],
                                         policy=P_NOVIRTUAL,
                                         backendoptimize=True)
        assert res

        res = self.timeshift_from_portal(main, recognizetable, [1],
                                         policy=P_NOVIRTUAL,
                                         backendoptimize=True)
        assert not res
Esempio n. 4
0
 def main(gets):
     auto = getautomaton()
     s = ["aaaaaaaaaab", "aaaa"][gets]
     return recognize3(auto, s)