Beispiel #1
0
    def test_complete_when_dfa_is_not_complete(self):
        """Test that when we try to make complete a non-complete SimpleDFA
        then the returned SimpleDFA is complete."""

        dfa = SimpleDFA(
            {"q0", "q1"},
            MapAlphabet({"a", "b"}),
            "q0",
            set(),
            {"q0": {"a": "q0", "b": "q1"}},
        )

        expected_dfa = SimpleDFA(
            {"q0", "q1", "sink"},
            MapAlphabet({"a", "b"}),
            "q0",
            set(),
            {
                "q0": {"a": "q0", "b": "q1"},
                "q1": {"a": "sink", "b": "sink"},
                "sink": {"a": "sink", "b": "sink"},
            },
        )

        actual_dfa = dfa.complete()
        assert actual_dfa == expected_dfa
Beispiel #2
0
    def test_complete_when_dfa_is_already_complete(self):
        """Test that when we try to make complete an already complete SimpleDFA
        then the returned SimpleDFA is equal to the previous one."""

        complete_dfa = SimpleDFA(
            {"q"}, MapAlphabet({"a"}), "q", set(), {"q": {"a": "q"}}
        )

        new_dfa = complete_dfa.complete()
        assert complete_dfa == new_dfa