Upsilon/UpsilonTests/GeneralTests/MathPrecedence.cs

31 lines
891 B
C#

using Upsilon.Evaluator;
using Xunit;
namespace UpsilonTests.GeneralTests
{
public class MathPrecedence : TestClass
{
public MathPrecedence(StaticScriptFixture fix) : base(fix)
{
}
[Theory]
[InlineData("5 * (10 + 5)", 75)]
[InlineData("(10 + 5) * 5", 75)]
public void Parenthesis(string input, double expectedOutput)
{
var actual = new Script(input, BoundScope, StaticScope).Evaluate<long>();
Assert.Equal(expectedOutput, actual, 8);
}
[Theory]
[InlineData("5 * 10 + 5", 55)]
[InlineData("5 + 10 * 5", 55)]
public void MultiplicationBeforeAddition(string input, double expectedOutput)
{
var actual = new Script(input, BoundScope, StaticScope).Evaluate<long>();
Assert.Equal(expectedOutput, actual, 8);
}
}
}