30 lines
751 B
C#
30 lines
751 B
C#
|
using Upsilon.BaseTypes;
|
||
|
using Upsilon.BaseTypes.Number;
|
||
|
using Upsilon.Evaluator;
|
||
|
using Xunit;
|
||
|
|
||
|
namespace UpsilonTests
|
||
|
{
|
||
|
public class FunctionTests
|
||
|
{
|
||
|
[Fact]
|
||
|
public void BasicFunctionTest()
|
||
|
{
|
||
|
const string input = @"
|
||
|
function testFunc ()
|
||
|
a = 100
|
||
|
end
|
||
|
a = 50
|
||
|
testFunc()
|
||
|
";
|
||
|
var script = new Script(input);
|
||
|
Assert.Empty(script.Diagnostics.Messages);
|
||
|
script.Evaluate();
|
||
|
Assert.Empty(script.Diagnostics.Messages);
|
||
|
Assert.True(script.Scope.TryGet("testFunc", out var func));
|
||
|
Assert.IsType<LuaFunction>(func);
|
||
|
Assert.True(script.Scope.TryGet("a", out var a));
|
||
|
Assert.Equal(100, (long)(NumberLong)a);
|
||
|
}
|
||
|
}
|
||
|
}
|