Improve debugging flow
This commit is contained in:
@@ -5,10 +5,10 @@ class RunStoryDemo {
|
|||||||
var input = Sys.stdin();
|
var input = Sys.stdin();
|
||||||
|
|
||||||
var debug = false;
|
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();
|
var path = input.readLine();
|
||||||
path = if (path.length == 0) {
|
path = if (path.length == 0) {
|
||||||
"examples/main.hank";
|
"examples/main/main.hank";
|
||||||
} else {
|
} else {
|
||||||
if (path.charAt(0) == '*') {
|
if (path.charAt(0) == '*') {
|
||||||
debug = true;
|
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);
|
story.loadScript(path);
|
||||||
var frame = StoryFrame.Finished;
|
var frame = StoryFrame.Finished;
|
||||||
do {
|
do {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class StoryTestCase extends utest.Test {
|
|||||||
try {
|
try {
|
||||||
frame = story.nextFrame();
|
frame = story.nextFrame();
|
||||||
} catch (e: Dynamic) {
|
} catch (e: Dynamic) {
|
||||||
trace('Error at ${story.lastLineID}');
|
trace('Error at ${story.lastLineID} while validating ${transcriptFile}');
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@@ -69,6 +69,7 @@ class StoryTestCase extends utest.Test {
|
|||||||
continue;
|
continue;
|
||||||
} else if (StringTools.startsWith(line, ">>>")) {
|
} else if (StringTools.startsWith(line, ">>>")) {
|
||||||
// Make the choice given.
|
// Make the choice given.
|
||||||
|
try {
|
||||||
var output = story.choose(Std.parseInt(StringTools.trim(line.substr(3))));
|
var output = story.choose(Std.parseInt(StringTools.trim(line.substr(3))));
|
||||||
if (debugPrints) {
|
if (debugPrints) {
|
||||||
trace(output);
|
trace(output);
|
||||||
@@ -77,6 +78,11 @@ class StoryTestCase extends utest.Test {
|
|||||||
// Assert that its output equals the transcript's expected choice output.
|
// Assert that its output equals the transcript's expected choice output.
|
||||||
Assert.equals(transcriptLines[++i], output);
|
Assert.equals(transcriptLines[++i], output);
|
||||||
}
|
}
|
||||||
|
} catch (e: Dynamic) {
|
||||||
|
trace('Error at ${story.lastLineID} while validating ${transcriptFile}');
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
} else if (StringTools.startsWith(line, "#")) {
|
} else if (StringTools.startsWith(line, "#")) {
|
||||||
// Allow comments in a transcript that need not be validated in any way
|
// Allow comments in a transcript that need not be validated in any way
|
||||||
if (debugPrints) {
|
if (debugPrints) {
|
||||||
|
|||||||
Reference in New Issue
Block a user