2018-11-21 13:49:59 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using Upsilon.Evaluator;
|
|
|
|
using Xunit;
|
|
|
|
|
2018-11-23 13:38:45 +00:00
|
|
|
namespace UpsilonTests.GeneralTests
|
2018-11-21 13:49:59 +00:00
|
|
|
{
|
2018-11-23 11:55:28 +00:00
|
|
|
public class UserDataListTests : TestClass
|
2018-11-21 13:49:59 +00:00
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void BasicArrayTest()
|
|
|
|
{
|
|
|
|
var arr = new[] {100, 30, 56, 213, 76787};
|
|
|
|
const string input = @"
|
|
|
|
function getValue(arr)
|
|
|
|
return arr[3]
|
|
|
|
end
|
|
|
|
";
|
2018-11-23 11:55:28 +00:00
|
|
|
var script = new Script(input, BoundScope, StaticScope);
|
2018-11-21 13:49:59 +00:00
|
|
|
Assert.Empty(script.Diagnostics.Messages);
|
|
|
|
var evaluated = script.EvaluateFunction<long>("getValue", new[] {arr});
|
|
|
|
Assert.Empty(script.Diagnostics.Messages);
|
|
|
|
Assert.Equal(56, evaluated);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void BasicListTest()
|
|
|
|
{
|
|
|
|
var arr = new List<int> {100, 30, 56, 213, 76787};
|
|
|
|
const string input = @"
|
|
|
|
function getValue(arr)
|
|
|
|
return arr[2]
|
|
|
|
end
|
|
|
|
";
|
2018-11-23 11:55:28 +00:00
|
|
|
var script = new Script(input, BoundScope, StaticScope);
|
2018-11-21 13:49:59 +00:00
|
|
|
Assert.Empty(script.Diagnostics.Messages);
|
|
|
|
var evaluated = script.EvaluateFunction<long>("getValue", new[] {arr});
|
|
|
|
Assert.Empty(script.Diagnostics.Messages);
|
|
|
|
Assert.Equal(30, evaluated);
|
|
|
|
}
|
|
|
|
|
2018-11-23 11:55:28 +00:00
|
|
|
public UserDataListTests(StaticScriptFixture fix) : base(fix)
|
|
|
|
{
|
|
|
|
}
|
2018-11-21 13:49:59 +00:00
|
|
|
}
|
|
|
|
}
|