Exemple #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'),
     )
Exemple #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')
Exemple #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')
Exemple #4
0
 def test_len(self):
     these_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.assertEqual(len(these_rules), 2)
Exemple #5
0
 def test_gt(self):
     over_dozen = gt(12)
     self.assertTrue(over_dozen(20))
     self.assertFalse(over_dozen(12))
     self.assertFalse(over_dozen(10))
Exemple #6
0
 def test_len(self):
     these_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.assertEqual(len(these_rules), 2)