Implements break statement

This commit is contained in:
2018-11-23 15:27:48 +01:00
parent d2c14d213c
commit 2db4d0607e
10 changed files with 76 additions and 13 deletions

View File

@@ -59,5 +59,25 @@ return a";
Assert.Equal(15, result);
}
[Fact]
public void NumericForLoopBreakTest()
{
const string input = @"
a = 0
for i=0,10 do
a = a + i
if i == 5 then
break
end
end
return a
";
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);
var result = script.Evaluate<long>();
Assert.Empty(script.Diagnostics.Messages);
Assert.Equal(15, result);
}
}
}

View File

@@ -14,9 +14,10 @@ namespace UpsilonTests.GeneralTests
{
const string input = @"
a = 10
if true then
function testFunc()
local a = 100
end
testFunc()
";
var script = new Script(input, BoundScope, StaticScope);
Assert.Empty(script.Diagnostics.Messages);