def test_for_all(self): some_predicate = for_all(pred(even), gt(0), lt(10)) self.assertTrue(some_predicate(4)) self.assertTrue(some_predicate(6)) self.assertFalse(some_predicate(3)) self.assertFalse(some_predicate(-2)) self.assertFalse(some_predicate(14))
def test_thrifty_conunction_and_disjunction(self): """Ако искате да тествате за това сменете raising_predicate с името на вашия 'хвърлящ' клас и го добавете в import-а""" number = pred(lambda x: True) | raising_predicate(5) number(5) number = pred(lambda x: False) & raising_predicate(17) self.assertRaises(number(17)) number = for_any(pred(lambda x: True), raising_predicate(5)) number(5) number = for_all(pred(lambda x: False), raising_predicate(5)) self.assertRaises(number(17))
def test_for_all(self): self.assertTrue(for_all()(1))
def test_for_all(self): pos_even_integer = for_all(gt(0), pred(lambda x: x % 2 == 0), oftype(int)) self.assertTrue(pos_even_integer(6)) self.assertFalse(pos_even_integer(1.5)) self.assertFalse(pos_even_integer(-1))
def test_for_all(self): pos_even_integer=for_all(gt(0), pred(lambda x: x%2==0), oftype(int)) self.assertTrue(pos_even_integer(6)) self.assertFalse(pos_even_integer(1.5)) self.assertFalse(pos_even_integer(-1))
def test_for_all_and_for_any_without_arguments(self): empty_all = for_all() empty_any = for_any() self.assertTrue(empty_all('baba')) self.assertFalse(empty_any('baba'))
def test_for_all(self): self.assertTrue(for_all(gt(0), lt(10))(5)) self.assertTrue(for_all(gt(0), lt(10), eq(5))(5)) self.assertFalse(for_all(gt(0), lt(10), eq(5))(7)) self.assertFalse(for_all(eq(0), eq(1))(0))