Rework type binding to allow for type awareness in iterators
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Upsilon;
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.Evaluator;
|
||||
using Xunit;
|
||||
|
||||
@@ -98,5 +99,21 @@ return value
|
||||
var actual = Executor.EvaluateScript<long>(input, Options);
|
||||
Assert.Equal(6, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GenericForLoopValueTypeBindTest()
|
||||
{
|
||||
const string input = @"
|
||||
arr = {100, 56, 28}
|
||||
for key, val in ipairs(arr) do
|
||||
a = val
|
||||
break
|
||||
end
|
||||
";
|
||||
var script = Executor.ParseInputAndEvaluate(input, Options);
|
||||
Assert.True(script.Bind().Scope.TryGetVariable("a", true, out var variable));
|
||||
Assert.Equal(Type.Number, variable.TypeContainer.Type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user