Esempio n. 1
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')
Esempio 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')
Esempio n. 3
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'),
     )
Esempio n. 4
0
 def test_len(self):
     these_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.assertEqual(len(these_rules), 2)
Esempio n. 5
0
 def test_len(self):
     these_rules = rules(
         (gt(0), 'positive'),
         (lt(0), 'negative'),
     )
     self.assertEqual(len(these_rules), 2)