public void DefineExpTest() { var exp = new Define(new Variable("x"), new Mul(new Number(4), new Add(new Number(8), new Number(1)))); var parameters = new ExpressionParameters(); var answer = exp.Execute(parameters); Assert.Equal(36.0, parameters.Variables["x"]); Assert.Equal("The value '4 * (8 + 1)' was assigned to the variable 'x'.", answer); }
public void DefineWithFuncTest() { var exp = new Define(new Variable("x"), new Sin(new Number(1))); var parameters = new ParameterCollection(); var expParams = new ExpressionParameters(AngleMeasurement.Radian, parameters); var answer = exp.Execute(expParams); Assert.Equal(Math.Sin(1), parameters["x"]); Assert.Equal("The value 'sin(1)' was assigned to the variable 'x'.", answer); }
public void DefineFuncWithParamsTest() { var uf = new UserFunction("s", 1); var func = new Sin(new Variable("x")); var exp = new Define(uf, func); var parameters = new ExpressionParameters(); var result = exp.Execute(parameters); Assert.Equal(func, parameters.Functions[uf]); Assert.Equal("The expression 'sin(x)' was assigned to the function 's(x1)'.", result); }
public void DefineFuncTest() { var uf = new UserFunction("s", new IExpression[0], 0); var func = new Sin(new Number(1)); var exp = new Define(uf, func); var parameters = new ExpressionParameters(); var result = exp.Execute(parameters); Assert.Equal(func, parameters.Functions[uf]); Assert.Equal("The expression 'sin(1)' was assigned to the function 's()'.", result); }
public void OverrideConstTest() { var exp = new Define(new Variable("π"), new Number(1)); var parameters = new ExpressionParameters(); exp.Execute(parameters); Assert.Equal(1.0, parameters.Variables["π"]); }
public void SimpDefineTest() { var exp = new Define(new Variable("x"), new Number(1)); var parameters = new ExpressionParameters(); var answer = exp.Execute(parameters); Assert.Equal(1.0, parameters.Variables["x"]); Assert.Equal("The value '1' was assigned to the variable 'x'.", answer); }