Пример #1
0
 def test_get_variables(self):
     self.assertSetEqual(
         OrStatement([
             VariableStatement('foo'),
             VariableStatement('foo'),
             VariableStatement('bar'),
             TrueStatement()
         ]).get_variables(), {'foo', 'bar'})
Пример #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(
         XnorStatement(VariableStatement('foo'),
                       VariableStatement('bar')).get_variables(),
         {'foo', 'bar'})
     self.assertSetEqual(
         XnorStatement(VariableStatement('foo'),
                       VariableStatement('foo')).get_variables(), {'foo'})
Пример #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_str(self):
     self.assertEqual(VariableStatement('foo').__str__(), 'foo')
Пример #6
0
 def test_evaluate(self):
     self.assertTrue(VariableStatement('foo').evaluate({'foo': True}))
     self.assertFalse(VariableStatement('bar').evaluate({'bar': False}))
     self.assertRaises(
         MissingVariableException,
         lambda: VariableStatement('foo').evaluate({'bar': False}))
Пример #7
0
 def test_get_variables(self):
     self.assertSetEqual(VariableStatement('foo').get_variables(), {'foo'})
Пример #8
0
 def test_str(self):
     self.assertEqual(
         NotStatement(VariableStatement('foo')).__str__(), "~foo")
Пример #9
0
 def test_str(self):
     self.assertEqual(
         XnorStatement(VariableStatement('foo'),
                       FalseStatement()).__str__(), "(foo = 0)")