Exception throwing when required, and fixes for unit tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Upsilon;
|
||||
using Upsilon.Evaluator;
|
||||
using Upsilon.Exceptions;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests.GeneralTests
|
||||
@@ -50,8 +51,7 @@ function testFunc (var1)
|
||||
end
|
||||
testFunc(100)
|
||||
";
|
||||
var script = Executor.ParseInputAndEvaluate(input, Options);
|
||||
Assert.True(script.HasVariable("testFunc"));
|
||||
Assert.Throws<ParseException>(() => Executor.ParseInputAndEvaluate(input, Options));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Upsilon;
|
||||
using Upsilon.Evaluator;
|
||||
using Upsilon.Exceptions;
|
||||
using Xunit;
|
||||
|
||||
namespace UpsilonTests.GeneralTests
|
||||
@@ -49,7 +50,7 @@ table = {
|
||||
}
|
||||
return table[""test""]
|
||||
";
|
||||
Executor.EvaluateScript<long>(input, Options);
|
||||
Assert.Throws<ParseException>(() => Executor.EvaluateScript<long>(input, Options));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -21,7 +21,7 @@ function getValue(arr)
|
||||
return arr[""here""]
|
||||
end
|
||||
";
|
||||
var evaluated = Executor.EvaluateScript<long>(input, Options);
|
||||
var evaluated = Executor.EvaluateFunction<long>(input, "getValue", new[] {arr}, Options);
|
||||
Assert.Equal(1683, evaluated);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ function getValue(arr)
|
||||
return arr[3]
|
||||
end
|
||||
";
|
||||
var evaluated = Executor.EvaluateScript<long>(input, Options);
|
||||
var evaluated = Executor.EvaluateFunction<long>(input, "getValue", new []{arr}, Options);
|
||||
Assert.Equal(56, evaluated);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ function getValue(arr)
|
||||
return arr[2]
|
||||
end
|
||||
";
|
||||
var evaluated = Executor.EvaluateScript<long>(input, Options);
|
||||
var evaluated = Executor.EvaluateFunction<long>(input, "getValue", new []{arr}, Options);
|
||||
Assert.Equal(30, evaluated);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using Upsilon;
|
||||
using Upsilon.BaseTypes.UserData;
|
||||
using Upsilon.Evaluator;
|
||||
using Upsilon.Exceptions;
|
||||
using Xunit;
|
||||
|
||||
// ReSharper disable UnusedMember.Local
|
||||
@@ -68,7 +69,7 @@ function test(o)
|
||||
o.FieldStringSet = ""Test""
|
||||
end
|
||||
";
|
||||
var result = Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options);
|
||||
Executor.EvaluateFunction(input, "test", new[] {obj}, Options);
|
||||
Assert.Equal("Test", obj.FieldStringSet);
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ function test(o)
|
||||
o.testMethod()
|
||||
end
|
||||
";
|
||||
Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options);
|
||||
Executor.EvaluateFunction(input, "test", new[] {obj}, Options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -106,7 +107,7 @@ function test(o)
|
||||
return o._privateTestField
|
||||
end
|
||||
";
|
||||
Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options);
|
||||
Assert.Throws<ParseException>(() => Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -118,7 +119,7 @@ function test(o)
|
||||
o.GetOnly = true
|
||||
end
|
||||
";
|
||||
Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options);
|
||||
Assert.Throws<ParseException>(() => Executor.EvaluateFunction(input, "test", new[] {obj}, Options));
|
||||
Assert.False(obj.GetOnly);
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ function test(o)
|
||||
o.PrivateSet = true
|
||||
end
|
||||
";
|
||||
Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options);
|
||||
Assert.Throws<ParseException>(() => Executor.EvaluateFunction<string>(input, "test", new[] {obj}, Options));
|
||||
Assert.False(obj.PrivateSet);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace UpsilonTests.StandardLibraryTests
|
||||
public void AssertTest()
|
||||
{
|
||||
Executor.EvaluateScript("assert(true)", Options);
|
||||
Assert.Throws<Exception>(() => Executor.EvaluateScript("assert(true)", Options));
|
||||
Assert.Throws<Exception>(() => Executor.EvaluateScript("assert(false)", Options));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user