Пример #1
0
 def testGivenExpressionWithOneVariableWhenAddExpressionWithOtherVariableAndConstantThenExpressionContainsAllTerms(
         self):
     variable1 = VariableBuilder().name('x').build()
     variable2 = VariableBuilder().name('y').build()
     constant = ConstantBuilder().value(1.0).build()
     expression1 = ExpressionBuilder().term(variable1).build()
     expression2 = ExpressionBuilder().term(variable2).term(
         constant).build()
     expression1.add_expression(expression2)
     self.assertEqual(expression1.get_name_set(),
                      {variable1.name, variable2.name})
     self.assertEqual(expression1.get_value_constant(), constant.value)
Пример #2
0
 def testGivenTwoExpressionsWithConstantsWhenAddExpressionThenExpressionDoesNotSimplify(
         self):
     expression = ExpressionBuilder().default_constant().build()
     expression.add_expression(expression.clon())
     self.assertRaises(NotSimplified, expression.get_value_constant)
Пример #3
0
 def testGivenEmptyExpressionWhenAddExpressionThenEqualsReturnsTrue(self):
     expression1 = ExpressionBuilder().build()
     expression2 = ExpressionBuilder().default_constant().default_variable(
     ).build()
     expression1.add_expression(expression2)
     self.assertTrue(expression1.equal(expression2))