Work on standard libraries.
- Allows Standard Libraries to work with actual luatypes, to prevent constant back and forth casting - adds ipairs function, doesn't do anything except maintain compatibility with lua - several tests
This commit is contained in:
@@ -25,5 +25,36 @@ namespace UpsilonTests.StandardLibraryTests
|
||||
Assert.Equal("test_error", e.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IPairsTest()
|
||||
{
|
||||
const string input = @"
|
||||
arr = {100, 56, 28}
|
||||
value = 0
|
||||
for key, val in ipairs(arr) do
|
||||
value = value + val
|
||||
end
|
||||
return value
|
||||
";
|
||||
var script = new Script(input, BoundScope, StaticScope);
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
var result = script.Evaluate<long>();
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
Assert.Equal(184, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ToNumberTest()
|
||||
{
|
||||
const string input = @"
|
||||
return tonumber(""100"")
|
||||
";
|
||||
var script = new Script(input, BoundScope, StaticScope);
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
var result = script.Evaluate<long>();
|
||||
Assert.Empty(script.Diagnostics.Messages);
|
||||
Assert.Equal(100, result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user