Upsilon/UpsilonTests/GeneralTests/MathPrecedence.cs

32 lines
878 B
C#
Raw Normal View History

2018-11-26 15:55:10 +00:00
using Upsilon;
2018-11-10 12:11:36 +00:00
using Upsilon.Evaluator;
using Xunit;
2018-11-23 13:38:45 +00:00
namespace UpsilonTests.GeneralTests
2018-11-10 12:11:36 +00:00
{
2018-11-23 11:55:28 +00:00
public class MathPrecedence : TestClass
2018-11-10 12:11:36 +00:00
{
2018-11-23 11:55:28 +00:00
public MathPrecedence(StaticScriptFixture fix) : base(fix)
{
}
2018-11-10 12:11:36 +00:00
[Theory]
[InlineData("5 * (10 + 5)", 75)]
[InlineData("(10 + 5) * 5", 75)]
public void Parenthesis(string input, double expectedOutput)
{
2018-11-26 15:55:10 +00:00
var actual = Executor.EvaluateScript<long>(input, Options);
2018-11-10 12:11:36 +00:00
Assert.Equal(expectedOutput, actual, 8);
}
[Theory]
[InlineData("5 * 10 + 5", 55)]
[InlineData("5 + 10 * 5", 55)]
public void MultiplicationBeforeAddition(string input, double expectedOutput)
{
2018-11-26 15:55:10 +00:00
var actual = Executor.EvaluateScript<long>(input, Options);
2018-11-10 12:11:36 +00:00
Assert.Equal(expectedOutput, actual, 8);
}
}
}