Improve debugging flow

This commit is contained in:
2019-01-25 11:02:37 -05:00
parent 712852673a
commit 843e01e888
2 changed files with 17 additions and 11 deletions

View File

@@ -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 {

View File

@@ -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