Esempio n. 1
0
    def test_phs(self):
        '''Suggested tests by Dr. Philippe (phs75).
        '''
        ea = LetterAtom('a')
        eb = LetterAtom('b')
        zs = StarAtom()
        a_s = StarAtom('a')
        bs = StarAtom('b')
        a_bs = StarAtom('a', 'b')
        ep = Product()

        assert ea.contains(zs)
        assert Product(ea).contains(ep)
        assert not ea.contains(a_s)
        assert a_s.contains(ea)
        assert a_s.contains(zs)
        assert Product(a_s).contains(ep)
        assert not a_s.contains(bs)
        assert not a_s.contains(a_bs)
        assert not ep.contains(ea)
        assert not ep.contains(a_s)
        assert not ep.contains(a_bs)
        assert not ep.contains(Product(ea, ea))
        assert ep.contains(ep)
        assert ep.contains(zs)
        assert ep.contains(Product(zs))
        assert ep.contains(Product(zs, zs))
        assert ea.contains(zs)
        assert Product(ea).contains(Product(zs, ep, ea, zs))
        assert not ea.contains(a_s)
        assert Product(a_s).contains(Product(ea, a_s))
        assert Product(a_s).contains(Product(ea, ep, zs, ea, a_s))
        assert Product(a_bs).contains(Product(ea, bs, a_s, bs))
        assert not Product(a_s).contains(Product(ea, a_bs, eb))
Esempio n. 2
0
    def test_StarAtom_naive_entailment_success(self, x):
        """
        Check that two StarAtoms, made from the same messages,
        contain each other.
        """
        e1 = StarAtom(*x)
        e2 = StarAtom(*x)

        assert e1.contains(e2) & e2.contains(e1)
Esempio n. 3
0
    def test_StarAtom_empty_entailment_failure(self, x):
        """
        Check that the empty StarAtom does not contain a non-empty StarAtom.
        """
        e1 = StarAtom(*x)
        e2 = StarAtom()

        assert not e2.contains(e1)
Esempio n. 4
0
    def test_StarAtom_empty_entailment_success(self, x):
        """
        Check that a StarAtom made with non-empty allowed messages contains
        the StarAtom made with the empty sequence.
        """
        e1 = StarAtom(*x)
        e2 = StarAtom()

        assert e1.contains(e2)
Esempio n. 5
0
    def test_Mixed_containment_failure(self, x):
        """
        Check that a LetterAtom cannot contain a StarAtom,
        and that a StarAtom contains a LetterAtom (when they're
        made from the same message).
        """
        e1 = LetterAtom(x)
        e2 = StarAtom(x)

        assert not e1.contains(e2)
        assert e2.contains(e1)
Esempio n. 6
0
    def test_StarAtom_entailment_success(self, x, y):
        """
        Input:
            x, y: sets of allowed messages

        e1 = StarAtom(x)
        e2 = StarAtom(x UNION y)

        Output:
            True (e2 contains e1)
        """
        z = set.union(x, y)
        e1 = StarAtom(*x)
        e2 = StarAtom(*z)

        assert e2.contains(e1)
Esempio n. 7
0
    def test_StarAtom_entailment_failure(self, x, y):
        """
        Input:
            x, y: sets of allowed messages

        e1 = StarAtom(x)
        e2 = StarAtom(x UNION y)

        Output:
            False (e1 does not contain e2)

        Note:
            Size constraints used to make sure the sets aren't identical.
        """
        z = set.union(x, y)
        e1 = StarAtom(*x)
        e2 = StarAtom(*z)

        assert not e1.contains(e2)