Пример #1
0
 def test_evaluate(self):
     self.assertTrue(
         XnorStatement(FalseStatement(), FalseStatement()).evaluate({}))
     self.assertFalse(
         XnorStatement(FalseStatement(), TrueStatement()).evaluate({}))
     self.assertFalse(
         XnorStatement(TrueStatement(), FalseStatement()).evaluate({}))
     self.assertTrue(
         XnorStatement(TrueStatement(), TrueStatement()).evaluate({}))
Пример #2
0
 def test_str(self):
     self.assertEqual(
         OrStatement([
             VariableStatement('foo'),
             VariableStatement('foo'),
             VariableStatement('bar'),
             TrueStatement()
         ]).__str__(), "(foo | foo | bar | 1)")
Пример #3
0
 def test_get_variables(self):
     self.assertSetEqual(
         OrStatement([
             VariableStatement('foo'),
             VariableStatement('foo'),
             VariableStatement('bar'),
             TrueStatement()
         ]).get_variables(), {'foo', 'bar'})
Пример #4
0
 def test_str(self):
     self.assertEqual(
         AndStatement([
             VariableStatement('foo'),
             VariableStatement('foo'),
             VariableStatement('bar'),
             TrueStatement()
         ]).__str__(), "(foo & foo & bar & 1)")
Пример #5
0
 def test_evaluate(self):
     self.assertTrue(OrStatement([TrueStatement()]).evaluate({}))
     self.assertFalse(OrStatement([FalseStatement()]).evaluate({}))
     self.assertTrue(
         OrStatement([TrueStatement(),
                      TrueStatement(),
                      TrueStatement()]).evaluate({}))
     self.assertTrue(
         OrStatement([TrueStatement(),
                      FalseStatement(),
                      TrueStatement()]).evaluate({}))
Пример #6
0
 def test_get_variables(self):
     self.assertSetEqual(TrueStatement().get_variables(), set())
Пример #7
0
 def test_str(self):
     self.assertEqual(TrueStatement().__str__(), '1')
Пример #8
0
 def test_evaluate(self):
     self.assertTrue(TrueStatement().evaluate({'a': True, 'b': False}))