Пример #1
0
 def testGivenExpressionWithTwoConstantsWhenSimplifyThenExpressionWithOneConstantWithCorrectValueIsObtained(
         self):
     constant1 = ConstantBuilder().build()
     expression = ExpressionBuilder().term(constant1).term(
         constant1).build()
     expression.simplify_constant()
     self.assertTrue(expression.get_value_constant(), 2 * constant1.value)
Пример #2
0
 def testGivenExpressionWithTwoVariablesWithSameNameWhenApplyAndSimplifyThenGetValueReturnsCorrectValue(
         self):
     expression = ExpressionBuilder().term(VariableBuilder().name('x').value(3.0).build()). \
         term(VariableBuilder().name('x').value(2.0).build()).build()
     expression.apply('x', 1.0)
     expression.simplify_constant()
     self.assertEqual(expression.get_value_constant(), 5.0)
Пример #3
0
 def testGivenExpressionWithTwoConstantsWithInverseValuesWhenSimplifyThenExpressionWithConstantWithValue0IsObtained(
         self):
     constant1 = ConstantBuilder().build()
     constant2 = constant1.clon()
     constant2.multiply(-1.0)
     expression = ExpressionBuilder().term(constant1).term(
         constant2).build()
     expression.simplify_constant()
     self.assertEqual(expression.get_value_constant(), 0.0)
Пример #4
0
 def testGivenEmpyExpressionWhenSimplifyThenEmptyExpressionIsObtained(self):
     expression = ExpressionBuilder().build()
     expression.simplify_constant()
     self.assertTrue(expression.empty())
Пример #5
0
 def testGivenExpressionWithOneConstantWhenSimplifyThenSameExpressionIsObtained(
         self):
     expression = ExpressionBuilder().default_constant().build()
     expression2 = expression.clon()
     expression.simplify_constant()
     self.assertTrue(expression.equal(expression2))