Exemple #1
0
 public void Build_MathExpr_MustReturnExpectedEvalValue()
 {
     Assert.AreEqual(21d, _service.Build("((1 + (1 + 1) * 10))").Eval());
     Assert.AreEqual(30d, _service.Build("((1) + (1 + 1)) * 10").Eval());
     Assert.AreEqual(12d, _service.Build("(((1 + 1 + 1 * 10)))").Eval());
     Assert.AreEqual(30d, _service.Build("((6 / (2 % 4) * 10))").Eval());
     Assert.AreEqual(1089000005d, _service.Build("108.9e7 + 1 * 10 / 2").Eval());
     Assert.AreEqual(26.364000000000004d, _service.Build("1.3 * 1.3 * 1.3 * 12").Eval());
     Assert.AreEqual(-1d, _service.Build("+-+-+-+-+-+1").Eval());
     Assert.AreEqual(1d, _service.Build("+-+-+-+-+--1").Eval());
     Assert.AreEqual(-2d, _service.Build("-1 + -1").Eval());
     Assert.AreEqual(-2d, _service.Build("-(1 + 1)").Eval());
     Assert.AreEqual(-2d, _service.Build("-AsAny(2)").Eval());
     Assert.AreEqual(2d, _service.Build("-AsAny(-2)").Eval());
     Assert.AreEqual(-1d, _service.Build("-(1)").Eval());
     Assert.AreEqual(-2d, _service.Build("-(AsAny(1 + 1))").Eval());
     Assert.AreEqual(-2d, _service.Build("-AsAny(1 + 1)").Eval());
 }