Example #1
0
 def test_dfa_union_side_effects(self):
     """ Tests that the union function doesn't make side
     effects on input NFAs """
     before_1 = copy.deepcopy(self.nfa_union_1_test_01)
     before_2 = copy.deepcopy(self.nfa_union_2_test_01)
     NFA.nfa_union(self.nfa_union_1_test_01, self.nfa_union_2_test_01)
     self.assertDictEqual(before_1, self.nfa_union_1_test_01)
     self.assertDictEqual(before_2, self.nfa_union_2_test_01)
Example #2
0
 def test_nfa_union_intersecting(self):
     """ Tests a nfa union between NFAs with some state in
     common """
     union = NFA.nfa_union(self.nfa_union_2_test_01,
                           self.nfa_union_3_test_01)
     # automata_IO.nfa_to_dot(union, 'nfa_union_intersecting')
     self.assertDictEqual(union, self.nfa_union_test_02_solution)
Example #3
0
 def test_nfa_union_djsoint(self):
     """ Tests a nfa union between NFAs with no state in
     common """
     union = NFA.nfa_union(self.nfa_union_1_test_01,
                           self.nfa_union_2_test_01)
     # automata_IO.nfa_to_dot(union, 'nfa_union')
     self.assertDictEqual(union, self.nfa_union_test_01_solution)
Example #4
0
 def disjunction(self, other):
     if self.special_attr == 'true' or other.special_attr == 'true':
         return self
     elif self.special_attr == 'false' or other.special_attr == 'false':
         return other
     else:
         aut_l, aut_r, new_var_map = self.augment_vars(other)
         return FiniteAutomaton(NFA.nfa_union(aut_l, aut_r), new_var_map)
Example #5
0
 def test_nfa_union_wrong_dict_2(self):
     """ Tests a dict() in input different from a well
     formatted dict() representing a NFA. [EXPECTED FAILURE]"""
     NFA.nfa_union(self.nfa_union_1_test_01, {'goofy': 'donald'})
Example #6
0
 def test_nfa_union_wrong_input_2(self):
     """ Tests an input different from a dict() object. [
     EXPECTED FAILURE] """
     NFA.nfa_union(self.nfa_union_2_test_01, 1)
Example #7
0
 def test_nfa_union_empty(self):
     """ Tests a nfa union where one of the input is an empty
     nfa """
     union = NFA.nfa_union(self.nfa_union_1_test_01,
                           self.nfa_union_test_03_empty)
     self.assertDictEqual(union, self.nfa_union_1_test_01)
Example #8
0
 def test_nfa_union_same(self):
     """ Tests a nfa union bewtween the same nfa """
     union = NFA.nfa_union(self.nfa_union_1_test_01,
                           self.nfa_union_1_test_01)
     # automata_IO.nfa_to_dot(union, 'nfa_union_same')
     self.assertDictEqual(union, self.nfa_union_1_test_01)