Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static decimal Round(decimal userNumber)
- {
- return Math.Round(userNumber);
- }
- public static decimal Round(decimal userNumber, int decimals)
- {
- return Math.Round(userNumber, decimals);
- }
- [Test]
- public void Stackoverflow_Issue()
- {
- var interpreter = new Interpreter();
- Func<decimal, decimal> roundFunction1 = (userNumber) => Round(userNumber);
- Func<decimal, int, decimal> roundFunction2 = (userNumber, decimals) => Round(userNumber, decimals);
- interpreter.SetFunction("ROUND", roundFunction1);
- interpreter.SetFunction("ROUND", roundFunction2);
- var x = 666.66M;
- interpreter.SetVariable("x", x);
- Assert.AreEqual(Round(x, 3), interpreter.Eval("ROUND(x, 3)"));
- Assert.AreEqual(Round(x, 1), interpreter.Eval("ROUND(x, 1)"));
- }
Advertisement
Add Comment
Please, Sign In to add comment