Tests for issue #47

This commit is contained in:
2019-03-26 11:27:21 -06:00
parent bd9aa11d61
commit efebbdf212
3 changed files with 22 additions and 2 deletions

View File

@@ -41,5 +41,14 @@ class HankAssert {
}
}
public static function throws(f: Void -> Void, ?message: String) {
try {
f();
Assert.fail("Expected an exception to be thrown");
} catch (e: String) {
if (message != null) {
Assert.equals(message, e);
}
}
}
}

View File

@@ -3,6 +3,7 @@ package tests;
import utest.Test;
import utest.Assert;
import hank.HankAssert;
using hank.Extensions;
import hank.HInterface;
import hank.StoryTree;
@@ -40,4 +41,14 @@ class HInterfaceTest extends utest.Test {
assertExpr('test2', true);
}
public function testNullErrors() {
HankAssert.throws(function() {
hInterface.evaluateExpr('undeclared_variable');
});
}
public function testIfIdiom() {
HankAssert.equals("", hInterface.evaluateExpr('if (false) "something"'));
}
}

View File

@@ -11,12 +11,12 @@ class StoryTest extends hank.StoryTestCase {
for (file in files) {
if (StringTools.endsWith(file, '.hlog')) {
trace(' Running ${file}');
var disabled = file.indexOf("disabled") != -1;
var debug = file.indexOf("debug") != -1;
var partial = file.indexOf("partial") != -1;
if (!disabled) {
trace(' Running ${file}');
validateAgainstTranscript('examples/${folder}/main.hank', 'examples/${folder}/${file}', !partial);
}
}