def test_afw_to_nfa_conversion_language_bis(self):
     """ Test a correct afw conversion to nfa comparing the language read 
     by the two automaton.
         Here we take a nfa, we covert it to afw and back to nfa,
         then the original and final nfa are compared trough the language 
         read.
     """
     original_nfa_to_afw = AFW.nfa_to_afw_conversion(
         self.nfa_afw_to_nfa_test_01)
     nfa_01 = AFW.afw_to_nfa_conversion(original_nfa_to_afw)
     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_nfa_acceptance = NFA.nfa_word_acceptance(
                 self.nfa_afw_to_nfa_test_01, word)
             nfa_acceptance = NFA.nfa_word_acceptance(nfa_01, word)
             self.assertEqual(original_nfa_acceptance, nfa_acceptance)
         i += 1
 def test_word_acceptance_check_side_effects(self):
     """ Tests that the function doesn't make any side effect on the
     input"""
     before = copy.deepcopy(self.nfa_word_acceptance_test_01)
     NFA.nfa_word_acceptance(self.nfa_word_acceptance_test_01,
                             ['a', 'a', 'b', 'b', 'a'])
     self.assertDictEqual(before, self.nfa_word_acceptance_test_01)
 def test_afw_to_nfa_conversion_language_bis_bis(self):
     """ Test a correct afw conversion to nfa comparing the language read 
     by the two automaton """
     nfa_01 = AFW.afw_to_nfa_conversion(self.afw_nonemptiness_check_test_2)
     # automata_IO.nfa_to_dot(nfa_01, 'afw_to_nfa_strange')
     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)
             afw_acceptance = AFW.afw_word_acceptance(
                 self.afw_nonemptiness_check_test_2, word)
             nfa_acceptance = NFA.nfa_word_acceptance(nfa_01, word)
             self.assertEqual(afw_acceptance, nfa_acceptance)
         i += 1
 def test_word_acceptance_wrong_input_2(self):
     """ Tests an input different from a list() object. [EXPECTED
     FAILURE]"""
     NFA.nfa_word_acceptance(self.nfa_word_acceptance_test_01, 1)
 def test_word_acceptance_wrong_dict(self):
     """ Tests a dict() in input different from a well formatted dict()
     representing a NFA. [EXPECTED FAILURE]"""
     NFA.nfa_word_acceptance({'goofy': 'donald'}, ['a', 'b', 'b', 'a', 'b'])
 def test_word_acceptance_wrong_input_1(self):
     """ Tests an input different from a dict() object. [EXPECTED
     FAILURE]"""
     NFA.nfa_word_acceptance(1, ['a', 'b', 'b', 'a', 'b'])
 def test_word_acceptance_empty_word(self):
     """ Tests an empty word"""
     self.assertFalse(
         NFA.nfa_word_acceptance(self.nfa_word_acceptance_test_empty, []))
 def test_word_acceptance_wrong_alphabet(self):
     """ Tests a non correct word, with letters not form the
     nfa alphabet """
     self.assertFalse(
         NFA.nfa_word_acceptance(self.nfa_word_acceptance_test_01,
                                 ['a', 'b', 'wrong']))
 def test_word_acceptance_false(self):
     """ Tests a non correct word, with good alphabet"""
     self.assertFalse(
         NFA.nfa_word_acceptance(self.nfa_word_acceptance_test_01,
                                 ['a', 'a', 'a']))
 def test_word_acceptance(self):
     """ Tests a correct word """
     self.assertTrue(
         NFA.nfa_word_acceptance(self.nfa_word_acceptance_test_01,
                                 ['a', 'b', 'b', 'a', 'b']))