diff --git a/hank/HankAssert.hx b/hank/HankAssert.hx index 7772fb3..df13a5e 100644 --- a/hank/HankAssert.hx +++ b/hank/HankAssert.hx @@ -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); + } + } + } } \ No newline at end of file diff --git a/tests/HInterfaceTest.hx b/tests/HInterfaceTest.hx index a583a9c..38fb967 100644 --- a/tests/HInterfaceTest.hx +++ b/tests/HInterfaceTest.hx @@ -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"')); + } + } diff --git a/tests/StoryTest.hx b/tests/StoryTest.hx index 78d7b4b..7e82108 100644 --- a/tests/StoryTest.hx +++ b/tests/StoryTest.hx @@ -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); } }