Reworked scope again

This commit is contained in:
2018-11-19 12:17:21 +01:00
parent 860f2cc7e5
commit 1f57eed3e7
6 changed files with 111 additions and 53 deletions

View File

@@ -123,5 +123,43 @@ return table[""func""]()()[1]()
Assert.Equal(100, evaluated);
}
[Fact]
public void ScopeInTables()
{
const string input = @"
table = {
local val = 400,
function test()
return val
end,
another = 10_000,
}
return table[""test""]()
";
var script = new Script(input);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.Evaluate<long>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal(400, evaluated);
}
[Fact]
public void UnnamedFunctionInTable()
{
const string input = @"
table = {
function()
return 400
end
}
return table[1]()
";
var script = new Script(input);
Assert.Empty(script.Diagnostics.Messages);
var evaluated = script.Evaluate<long>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal(400, evaluated);
}
}
}