test_AFW.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:PySimpleAutomata 作者: Oneiroe 项目源码 文件源码
def test_afw_union_equals(self):
        """ Tests a correct afw union with the same afw """
        AFW.rename_afw_states(self.afw_union_1_test_01, 'a_')
        union = AFW.afw_union(self.afw_union_1_test_01,
                              self.afw_union_1_test_01)

        i = 0
        last = 7
        while i <= last:
            base = list(itertools.repeat('a', i))
            base += list(itertools.repeat('b', i))
            # build all permutation of 'a' and 'b' till length i
            word_set = set(itertools.permutations(base, i))
            for word in word_set:
                word = list(word)
                original_acceptance_1 = AFW.afw_word_acceptance(
                    self.afw_union_1_test_01, word)
                original_acceptance_2 = AFW.afw_word_acceptance(
                    self.afw_union_1_test_01, word)
                union_acceptance = AFW.afw_word_acceptance(union, word)
                self.assertEqual(
                    original_acceptance_1 or original_acceptance_2,
                    union_acceptance)
            i += 1
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号