2018-11-23 12:34:46 +00:00
|
|
|
using System;
|
2018-11-21 19:59:27 +00:00
|
|
|
using Upsilon.Evaluator;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace UpsilonTests.StandardLibraryTests
|
|
|
|
{
|
2018-11-23 11:55:28 +00:00
|
|
|
public class BasicFunctionsTests : TestClass
|
2018-11-21 19:59:27 +00:00
|
|
|
{
|
2018-11-23 11:55:28 +00:00
|
|
|
public BasicFunctionsTests(StaticScriptFixture fix) : base(fix)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-21 19:59:27 +00:00
|
|
|
[Fact]
|
2018-11-23 12:34:46 +00:00
|
|
|
public void AssertTest()
|
2018-11-21 19:59:27 +00:00
|
|
|
{
|
2018-11-23 11:55:28 +00:00
|
|
|
new Script("assert(true)", BoundScope, StaticScope).Evaluate();
|
2018-11-23 12:34:46 +00:00
|
|
|
Assert.Throws<Exception>(() => new Script("assert(false)", BoundScope, StaticScope).Evaluate());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void Error()
|
|
|
|
{
|
|
|
|
var e = Assert.Throws<Exception>(() =>
|
|
|
|
new Script(@"error(""test_error"")", BoundScope, StaticScope).Evaluate());
|
|
|
|
Assert.Equal("test_error", e.Message);
|
2018-11-21 19:59:27 +00:00
|
|
|
}
|
2018-11-23 11:55:28 +00:00
|
|
|
|
2018-11-21 19:59:27 +00:00
|
|
|
}
|
|
|
|
}
|