def test_empty_star_in_letter(self, x): """ Check that the empty StarAtom is in an arbitrary LetterAtom. """ e1 = LetterAtom(x) e2 = StarAtom() assert e1.contains(e2)
def test_single_write(self): e1 = StarAtom("start", "stop") p1 = Product(e1) p2 = p1.write("test") s1 = SRE(p1) s2 = s1.write("test") assert p2.contains(LetterAtom("test")) assert s2.contains(SRE(Product(LetterAtom("test"))))
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)
def test_LetterAtom_absorption(self, x): """ Check that a LetterAtom does not absorb itself, it does not absorb another LetterAtom made from the same message, but only absorbs an empty StarAtom. """ e1 = LetterAtom(x) e2 = LetterAtom(x) e3 = StarAtom() assert not e1.absorbs(e1) assert not e1.absorbs(e2) assert e1.absorbs(e3)
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))
def test_StarAtom_absorption(self, x, y): """Check that a StarAtom absorbs a LetterAtom made of the same message, and that it is absorbed by a StarAtom made of (at least) the same message. """ e1 = StarAtom(x) e2 = LetterAtom(x) e3 = StarAtom(x, y) assert e1.absorbs(e2) assert e3.absorbs(e1)
def test_single_read(self): e1 = StarAtom("start", "stop") e2 = LetterAtom("reset") p1 = Product(e1, e2) p2 = p1.read("reset") s1 = SRE(p1) s2 = s1.read("reset") assert not s2.messages() assert not p2.messages()
def test_LetterAtom_naive_entailment_success(self, x): """ Check that two LetterAtoms made with the same message entail each other. """ e1 = LetterAtom(x) e2 = LetterAtom(x) assert e1.contains(e2) & e2.contains(e1)
def test_simple_creation(self): """Check that we can plainly create an SRE from atoms or from products. """ e1 = StarAtom("start", "stop") e2 = LetterAtom("reset") e3 = StarAtom("help") p1 = Product(e1, e2) p2 = Product(e3) s1 = SRE(p1, p2) s2 = SRE(e1, e2, e3) assert s1 assert s2
def test_LetterAtom_single_letter(self, x): """ Check that we can create a LetterAtom using an allowed message. """ e1 = LetterAtom(x) assert e1
def test_letter_atom(self, x): e1 = LetterAtom(x) p = Product(e1) assert p
def test_two_mixed_atoms(self, x, y): e1 = StarAtom(*x) e2 = LetterAtom(y) p = Product(e1, e2) assert p
def test_LetterAtom_empty_create(self): """ Check that we cannot create a LetterAtom without passing a message. """ LetterAtom()
def test_LetterAtom_empty_string_create(self): """ Check that we cannot create a LetterAtom with an empty string. """ LetterAtom("")
def test_LetterAtom_creation(self): """ Check that we can create a LetterAtom with a single message. """ e1 = LetterAtom('a') assert e1
def test_LetterAtom_more_than_one_bad_message(self, x): """ Check that LetterAtom creation fails when more than one bad message is passed. """ LetterAtom(*x)
def test_LetterAtom_create_with_bad_message(self, x): """ Check that LetterAtom creation fails with a forbidden message. The pattern should be changed if ALLOWED_MESSAGES is changed. """ LetterAtom(x)