Upsilon/UpsilonTests/GeneralTests/UserDataDictionaryTests.cs

34 lines
917 B
C#

using System.Collections.Generic;
using Upsilon.Evaluator;
using Xunit;
namespace UpsilonTests.GeneralTests
{
public class UserDataDictionaryTests : TestClass
{
[Fact]
public void BasicStringKeyed()
{
var arr = new Dictionary<string, int>
{
{"test", 100},
{"1234", 90},
{"here", 1683},
};
const string input = @"
function getValue(arr)
return arr[""here""]
end
";
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.EvaluateFunction<long>("getValue", new[] {arr});
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal(1683, evaluated);
}
public UserDataDictionaryTests(StaticScriptFixture fix) : base(fix)
{
}
}
}