示例#1
0
    def test_afw_complementation_empty_transitions(self):
        """ Tests a complementation of a afw without transitions"""
        self.afw_complementation_test_01['transitions'] = {}
        result = copy.deepcopy(self.afw_complementation_test_01)
        result['accepting_states'] = {'q1', 'q2'}
        for state in result['states']:
            for action in result['alphabet']:
                result['transitions'][state, action] = 'True'

        complemented = AFW.afw_complementation(
            self.afw_complementation_test_01)
        self.assertEqual(complemented, result)
示例#2
0
    def test_afw_complementation(self):
        """ Test a correct afw complementation comparing the language read, 
        that must be discording"""
        afw_complemented = AFW.afw_complementation(
            self.afw_complementation_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)
                afw_acceptance = AFW.afw_word_acceptance(
                    self.afw_complementation_test_01, word)
                complement_acceptance = AFW.afw_word_acceptance(
                    afw_complemented, word)
                self.assertNotEqual(afw_acceptance, complement_acceptance)
            i += 1
示例#3
0
 def test_afw_complementation_side_effects(self):
     """ Tests the function doesn't make any side effect on the input """
     before = copy.deepcopy(self.afw_complementation_test_01)
     AFW.afw_complementation(self.afw_complementation_test_01)
     self.assertDictEqual(before, self.afw_complementation_test_01)
示例#4
0
 def test_afw_complementation_wrong_dict(self):
     """ Tests a dict() in input different from a well formatted dict() 
     representing a DFA. [EXPECTED FAILURE]"""
     AFW.afw_complementation({'goofy': 'donald'})
示例#5
0
 def test_afw_complementation_wrong_input(self):
     """ Tests an input different from a dict() object. [EXPECTED 
     FAILURE]"""
     AFW.afw_complementation(0)
示例#6
0
 def test_afw_complementation_empty_states(self):
     """ Tests a complementation of a afw without states"""
     complemented = AFW.afw_complementation(
         self.afw_complementation_test_empty)
     self.assertEqual(complemented, self.afw_complementation_test_empty)