Ejemplo n.º 1
0
 def testGivenExpressionWithOneVariableWhenSimplifyNameThenSameExpressionIsObtained(
         self):
     variable = VariableBuilder().build()
     expression = ExpressionBuilder().term(variable).build()
     expression2 = expression.clon()
     expression.simplify_variable(variable.name)
     self.assertTrue(expression.equal(expression2))
Ejemplo n.º 2
0
 def testGivenExpressionWithVariableWhenAddZeroValueVariableThenNoVariableIsAdded(
         self):
     expression = ExpressionBuilder().default_variable().build()
     expression_original = expression.clon()
     zero = VariableBuilder().value(0).build()
     expression.add_term(zero)
     self.assertEqual(str(expression), str(expression_original))
Ejemplo n.º 3
0
 def testGivenNotEmptyExpressionWhenClonThenExpressionEqualsReturnsTrue(
         self):
     expression = ExpressionBuilder().default_constant().default_variable(
     ).default_variable().build()
     expression_clon = expression.clon()
     self.assertFalse(expression is expression_clon)
     self.assertTrue(expression.equal(expression_clon))
Ejemplo n.º 4
0
 def testGivenExpressionWithOneConstantWhenSimplifyThenSameExpressionIsObtained(
         self):
     expression = ExpressionBuilder().default_constant().build()
     expression2 = expression.clon()
     expression.simplify_constant()
     self.assertTrue(expression.equal(expression2))
Ejemplo n.º 5
0
 def testGivenTwoExpressionsWithConstantsWhenAddExpressionThenExpressionDoesNotSimplify(
         self):
     expression = ExpressionBuilder().default_constant().build()
     expression.add_expression(expression.clon())
     self.assertRaises(NotSimplified, expression.get_value_constant)
Ejemplo n.º 6
0
 def testGivenExpressionWithConstantWhenAddZeroThenNoConstantIsAdded(self):
     expression = ExpressionBuilder().default_constant().build()
     expression_original = expression.clon()
     zero = ConstantBuilder().value(0).build()
     expression.add_term(zero)
     self.assertEqual(str(expression), str(expression_original))