From 843e01e8881d34803c1594d0a4a118b0afcb9ecd Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 25 Jan 2019 11:02:37 -0500 Subject: [PATCH] Improve debugging flow --- src/RunStoryDemo.hx | 6 +++--- src/StoryTestCase.hx | 22 ++++++++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/RunStoryDemo.hx b/src/RunStoryDemo.hx index eb9bc52..5d93389 100644 --- a/src/RunStoryDemo.hx +++ b/src/RunStoryDemo.hx @@ -5,10 +5,10 @@ class RunStoryDemo { var input = Sys.stdin(); var debug = false; - trace("Enter a path to a hank story file. Prepend with * for debug prints. (default is examples/main.hank): "); + trace("Enter a path to a hank story file. Prepend with * for debug prints. (default is examples/main/main.hank): "); var path = input.readLine(); path = if (path.length == 0) { - "examples/main.hank"; + "examples/main/main.hank"; } else { if (path.charAt(0) == '*') { debug = true; @@ -18,7 +18,7 @@ class RunStoryDemo { } } - var story: Story = new Story(false, StringTools.replace(path, '.hank', '.hog')); + var story: Story = new Story(false, StringTools.replace(path, '.hank', '.hlog')); story.loadScript(path); var frame = StoryFrame.Finished; do { diff --git a/src/StoryTestCase.hx b/src/StoryTestCase.hx index 5b61a66..0d75580 100644 --- a/src/StoryTestCase.hx +++ b/src/StoryTestCase.hx @@ -37,7 +37,7 @@ class StoryTestCase extends utest.Test { try { frame = story.nextFrame(); } catch (e: Dynamic) { - trace('Error at ${story.lastLineID}'); + trace('Error at ${story.lastLineID} while validating ${transcriptFile}'); throw e; } @@ -69,13 +69,19 @@ class StoryTestCase extends utest.Test { continue; } else if (StringTools.startsWith(line, ">>>")) { // Make the choice given. - var output = story.choose(Std.parseInt(StringTools.trim(line.substr(3)))); - if (debugPrints) { - trace(output); - } - if (fullTranscript || transcriptLines.length > i+1) { - // Assert that its output equals the transcript's expected choice output. - Assert.equals(transcriptLines[++i], output); + try { + var output = story.choose(Std.parseInt(StringTools.trim(line.substr(3)))); + if (debugPrints) { + trace(output); + } + if (fullTranscript || transcriptLines.length > i+1) { + // Assert that its output equals the transcript's expected choice output. + Assert.equals(transcriptLines[++i], output); + } + } catch (e: Dynamic) { + trace('Error at ${story.lastLineID} while validating ${transcriptFile}'); + + throw e; } } else if (StringTools.startsWith(line, "#")) { // Allow comments in a transcript that need not be validated in any way