42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Upsilon.Evaluator;
|
|
using Xunit;
|
|
|
|
namespace UpsilonTests
|
|
{
|
|
public class UserDataListTests
|
|
{
|
|
[Fact]
|
|
public void BasicArrayTest()
|
|
{
|
|
var arr = new[] {100, 30, 56, 213, 76787};
|
|
const string input = @"
|
|
function getValue(arr)
|
|
return arr[3]
|
|
end
|
|
";
|
|
var script = new Script(input);
|
|
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
|
|
";
|
|
var script = new Script(input);
|
|
Assert.Empty(script.Diagnostics.Messages);
|
|
var evaluated = script.EvaluateFunction<long>("getValue", new[] {arr});
|
|
Assert.Empty(script.Diagnostics.Messages);
|
|
Assert.Equal(30, evaluated);
|
|
}
|
|
|
|
}
|
|
} |