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({}))
def test_str(self): self.assertEqual( OrStatement([ VariableStatement('foo'), VariableStatement('foo'), VariableStatement('bar'), TrueStatement() ]).__str__(), "(foo | foo | bar | 1)")
def test_get_variables(self): self.assertSetEqual( OrStatement([ VariableStatement('foo'), VariableStatement('foo'), VariableStatement('bar'), TrueStatement() ]).get_variables(), {'foo', 'bar'})
def test_str(self): self.assertEqual( AndStatement([ VariableStatement('foo'), VariableStatement('foo'), VariableStatement('bar'), TrueStatement() ]).__str__(), "(foo & foo & bar & 1)")
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({}))
def test_get_variables(self): self.assertSetEqual(TrueStatement().get_variables(), set())
def test_str(self): self.assertEqual(TrueStatement().__str__(), '1')
def test_evaluate(self): self.assertTrue(TrueStatement().evaluate({'a': True, 'b': False}))