Example #1
0
 def test_nfa_intersection_side_effects(self):
     """ Tests that the intersection function doesn't make
     side effects on input DFAs"""
     before_1 = copy.deepcopy(self.nfa_intersection_1_test_01)
     before_2 = copy.deepcopy(self.nfa_intersection_2_test_01)
     NFA.nfa_intersection(self.nfa_intersection_1_test_01,
                          self.nfa_intersection_2_test_01)
     self.assertDictEqual(before_1, self.nfa_intersection_1_test_01)
     self.assertDictEqual(before_2, self.nfa_intersection_2_test_01)
Example #2
0
 def conjunction(self, other):
     if self.special_attr == 'true' or other.special_attr == 'false':
         return other
     elif self.special_attr == 'false' or other.special_attr == 'true':
         return self
     else:
         aut_l, aut_r, new_var_map = self.augment_vars(other)
         return FiniteAutomaton(NFA.nfa_intersection(aut_l, aut_r),
                                new_var_map)
Example #3
0
 def test_nfa_intersection_wrong_dict_2(self):
     """ Tests a dict() in input different from a well
     formatted dict() representing a NFA. [EXPECTED FAILURE]"""
     NFA.nfa_intersection(self.nfa_intersection_1_test_01,
                          {'goofy': 'donald'})
Example #4
0
 def test_nfa_intersection_wrong_input_2(self):
     """ Tests an input different from a dict() object. [
     EXPECTED FAILURE] """
     NFA.nfa_intersection(self.nfa_intersection_1_test_01, 0)
Example #5
0
 def test_nfa_intersection_empty(self):
     """ Tests a NFAs intersection where one of them is empty """
     intersection = NFA.nfa_intersection(
         self.nfa_intersection_1_test_01,
         self.nfa_intersection_test_02_empty)
     self.assertDictEqual(intersection, self.nfa_intersection_test_02_empty)
Example #6
0
 def test_nfa_intersection(self):
     """ Tests a correct NFAs intersection """
     intersection = NFA.nfa_intersection(self.nfa_intersection_1_test_01,
                                         self.nfa_intersection_2_test_01)
     self.assertDictEqual(intersection,
                          self.nfa_intersection_test_01_solution)