Add Numeric For Loops
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class BasicMathExpressions : TestClass
|
||||
{
|
||||
|
||||
63
UpsilonTests/GeneralTests/ForLoopTests.cs
Normal file
63
UpsilonTests/GeneralTests/ForLoopTests.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class ForLoopTests : TestClass
|
||||
{
|
||||
public ForLoopTests(StaticScriptFixture fix) : base(fix)
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BasicNumericForLoopTest()
|
||||
{
|
||||
const string input = @"
|
||||
a = 0
|
||||
for i=0,5 do
|
||||
a = a + i
|
||||
end
|
||||
return a
|
||||
";
|
||||
var script = new Script(input, BoundScope, StaticScope);
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
var result = script.Evaluate<long>();
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
Assert.Equal(15, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NumericForLoopWithDifferentStepTest()
|
||||
{
|
||||
const string input = @"
|
||||
a = 0
|
||||
for i=0,10,2 do
|
||||
a = a + i
|
||||
end
|
||||
return a
|
||||
";
|
||||
var script = new Script(input, BoundScope, StaticScope);
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
var result = script.Evaluate<long>();
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
Assert.Equal(30, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NumericForLoopWithNegativeStepTest()
|
||||
{
|
||||
const string input = @"
|
||||
a = 0
|
||||
for i=5,0,-1 do
|
||||
a = a + i
|
||||
end
|
||||
return a";
|
||||
var script = new Script(input, BoundScope, StaticScope);
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
var result = script.Evaluate<long>();
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
Assert.Equal(15, result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class FunctionTests : TestClass
|
||||
{
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class IfTests : TestClass
|
||||
{
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.Evaluator;
|
||||
using Upsilon.Parser;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class MathPrecedence : TestClass
|
||||
{
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class ScopeTests : TestClass
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class StringTests : TestClass
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class TableTests : TestClass
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class UserDataDictionaryTests : TestClass
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class UserDataListTests : TestClass
|
||||
{
|
||||
|
||||
@@ -2,10 +2,11 @@ using System;
|
||||
using Upsilon.BaseTypes.UserData;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable ClassNeverInstantiated.Global
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class UserDataOperatorTests : TestClass, IClassFixture<UserDataOperatorTests.UserDataOperatorTestsFixture>
|
||||
{
|
||||
|
||||
@@ -2,9 +2,10 @@ using System;
|
||||
using Upsilon.BaseTypes.UserData;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
// ReSharper disable UnusedMember.Local
|
||||
|
||||
namespace UpsilonTests
|
||||
namespace UpsilonTests.GeneralTests
|
||||
{
|
||||
public class UserDataTests : TestClass, IClassFixture<UserDataTests.UserDataTestsFixture>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user