Reworked scope again
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user