def test_afw_union_intersecting(self): """ Tests a correct afw union where the afws have some state in common """ AFW.rename_afw_states(self.afw_union_3_test_01, 'a_') union = AFW.afw_union(self.afw_union_1_test_01, self.afw_union_3_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) # print(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_3_test_01, word) union_acceptance = AFW.afw_word_acceptance(union, word) self.assertEqual( original_acceptance_1 or original_acceptance_2, union_acceptance) i += 1
def test_afw_intersection_equals(self): """ Tests a correct afw intersection with the same afw """ AFW.rename_afw_states(self.afw_intersection_1_test_01, 'a_') intersection = AFW.afw_intersection(self.afw_intersection_1_test_01, self.afw_intersection_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_intersection_1_test_01, word) original_acceptance_2 = AFW.afw_word_acceptance( self.afw_intersection_1_test_01, word) intersection_acceptance = AFW.afw_word_acceptance(intersection, word) self.assertEqual( original_acceptance_1 and original_acceptance_2, intersection_acceptance) i += 1
def test_afw_union_disjoint(self): """ Tests a correct afw union with completely disjoint afws """ AFW.rename_afw_states(self.afw_union_2_test_01, 'a_') union = AFW.afw_union(self.afw_union_1_test_01, self.afw_union_2_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_2_test_01, word) union_acceptance = AFW.afw_word_acceptance(union, word) self.assertEqual( original_acceptance_1 or original_acceptance_2, union_acceptance) i += 1