Exemplo n.º 1
0
 def setUp(self):
     self.positivity_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.type_rules = rules(
         (is_number, rules(
             (gt(0), 'positive number'),
             (eq(0), 'zero'),
             (lt(0), 'negative number'),
         )),
         (is_string, 'string'),
         (otherwise, 'unhandled type'),
     )
Exemplo n.º 2
0
 def test_addition(self):
     rules1 = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     rules2 = rules((eq(0), 'zero'), )
     these_rules = rules1 + rules2
     self.assertEqual(len(these_rules), 3)
     self.assertEqual(decide(these_rules, 0), 'zero')
Exemplo n.º 3
0
 def test_addition(self):
     rules1 = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     rules2 = rules(
         (eq(0), 'zero'),
     )
     these_rules = rules1 + rules2
     self.assertEqual(len(these_rules), 3)
     self.assertEqual(decide(these_rules, 0), 'zero')
Exemplo n.º 4
0
 def test_len(self):
     these_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.assertEqual(len(these_rules), 2)
Exemplo n.º 5
0
 def test_lt(self):
     less_than_ten = lt(10)
     self.assertTrue(less_than_ten(8))
     self.assertFalse(less_than_ten(10))
     self.assertFalse(less_than_ten(20))
Exemplo n.º 6
0
 def test_len(self):
     these_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.assertEqual(len(these_rules), 2)