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:
2018-11-24 13:35:40 +01:00
parent 806b3d5689
commit c63df3c941
13 changed files with 88 additions and 42 deletions

View File

@@ -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);
}
}
}