Adds Unary length operator

This commit is contained in:
2018-11-24 15:11:33 +01:00
parent 2dc59c5f8b
commit cd04486d16
12 changed files with 88 additions and 12 deletions

View File

@@ -0,0 +1,27 @@
using Upsilon.Binder;
using Upsilon.Evaluator;
using Upsilon.StandardLibraries;
using Xunit;
namespace UpsilonTests.GeneralTests
{
public class LengthOperatorTests : TestClass
{
public LengthOperatorTests(StaticScriptFixture fix) : base(fix)
{
}
[Theory]
[InlineData(@"#""test""", 4)]
[InlineData(@"#{100,50,60,7863,1564,12354,10354}", 7)]
public void Test(string input, long expectedOutput)
{
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);
var actual = script.Evaluate<long>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal(expectedOutput, actual);
}
}
}

View File

@@ -26,7 +26,7 @@ namespace UpsilonTests.StandardLibraryTests
}
[Fact]
public void IPairsTest()
public void UpTillNilPairsTest()
{
const string input = @"
arr = {100, 56, 28, nil, 100}