More unit tests

This commit is contained in:
Deukhoofd 2018-11-23 13:34:46 +01:00
parent 8d6d6e45af
commit 1928979b40
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
3 changed files with 14 additions and 7 deletions

View File

@ -1,3 +1,4 @@
using System;
using Upsilon.Evaluator; using Upsilon.Evaluator;
using Xunit; using Xunit;
@ -10,9 +11,18 @@ namespace UpsilonTests.StandardLibraryTests
} }
[Fact] [Fact]
public void Assert() public void AssertTest()
{ {
new Script("assert(true)", BoundScope, StaticScope).Evaluate(); new Script("assert(true)", BoundScope, StaticScope).Evaluate();
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);
} }
} }

View File

@ -1,8 +1,5 @@
using System.Collections.Generic;
using Upsilon.BaseTypes;
using Upsilon.Binder; using Upsilon.Binder;
using Upsilon.Evaluator; using Upsilon.Evaluator;
using Upsilon.StandardLibraries;
using Xunit; using Xunit;
namespace UpsilonTests namespace UpsilonTests
@ -10,10 +7,10 @@ namespace UpsilonTests
[Collection("collection")] [Collection("collection")]
public abstract class TestClass public abstract class TestClass
{ {
public EvaluationScope StaticScope { get; } protected EvaluationScope StaticScope { get; }
public BoundScope BoundScope { get; } protected BoundScope BoundScope { get; }
public TestClass(StaticScriptFixture fix) protected TestClass(StaticScriptFixture fix)
{ {
StaticScope = fix.StaticScope; StaticScope = fix.StaticScope;
BoundScope = fix.BoundScope; BoundScope = fix.BoundScope;