Proving that tests stop prematurely

This commit is contained in:
2019-05-15 11:09:48 -06:00
parent d6e8d39762
commit 9e1ad0d7a4
9 changed files with 57 additions and 25 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@ examples/petIntersection/
transcript.hlog
validating.hlog
js/hank.js
cpp/

View File

@@ -1,15 +0,0 @@
package hank;
import haxe.macro.Expr;
import haxe.macro.Context;
class DebugMacros {
public static macro function watch(e: Expr): Expr {
switch (e.expr) {
case EConst(CIdent(i)):
return macro trace('$i:' + $e);
default:
throw 'Can only watch variables (for now)';
}
}
}

View File

@@ -27,5 +27,27 @@ class LogUtil {
trace(linesFromFile);
}
}
public static macro function watch(e: Expr): Expr {
switch (e.expr) {
case EConst(CIdent(i)):
return macro trace('$i:' + $e);
default:
throw 'Can only watch variables (for now)';
}
}
public static function currentTarget(): String {
#if js
return "js";
#end
#if cpp
return "cpp";
#end
#if interp
return "interp";
#end
return "unknown";
}
}

View File

@@ -1,7 +1,7 @@
package hank;
import haxe.ds.Option;
import hank.DebugMacros.watch;
import hank.LogUtil.watch;
@:allow(tests.StoryTreeTest)
class StoryNode {

View File

@@ -1,12 +1,30 @@
-js out.js
-cmd node out.js
hxml/all.hxml
-cp hank
-lib hscript
-lib utest
--each
-cpp cpp
hxml/internals.hxml
--next
-cpp cpp
hxml/examples.hxml
--next
-js js/hank.js
-cmd node js/hank.js
hxml/internals.hxml
--next
-js js/hank.js
-cmd node js/hank.js
hxml/examples.hxml
--next
--interp
hxml/all.hxml
hxml/internals.hxml
--next
-cpp
hxml/all.hxml
--interp
hxml/examples.hxml
--next

View File

@@ -11,6 +11,7 @@ import hank.HankAssert;
Maybe a better way to test parsing would be to execute individual lines?? idk
**/
@:build(hank.FileLoadingMacro.build(["examples/parsing/"]))
class ParserTest extends utest.Test {
var ast: HankAST;
@@ -26,7 +27,7 @@ class ParserTest extends utest.Test {
function testParseOutput() {
var parser = new Parser();
ast = parser.parseFile('examples/parsing/output.hank');
ast = parser.parseFile('examples/parsing/output.hank', files);
assertNextExpr(EOutput(new Output([Text("This file contains test cases for output expression parsing.")])));
assertNextExpr(EOutput(new Output([Text("A line won't be interrupted or anything.")])));
assertNextExpr(EOutput(new Output([Text("Multiline comments an output expression. This should parse as one line of output.")])));
@@ -102,7 +103,7 @@ class ParserTest extends utest.Test {
function testParseMisc() {
var parser = new Parser();
ast = parser.parseFile('examples/parsing/misc.hank');
ast = parser.parseFile('examples/parsing/misc.hank', files);
assertNextExpr(EHaxeLine('var demo_var = "dynamic content";'));
assertNextExpr(EKnot("knot_example"));
assertNextExpr(EKnot("knot_example"));

View File

@@ -6,6 +6,7 @@ import hank.StoryTree;
import hank.Parser;
using hank.Extensions;
@:build(hank.FileLoadingMacro.build(["examples/diverts/"]))
class StoryTreeTest extends utest.Test {
var tree: StoryNode;
@@ -38,7 +39,7 @@ class StoryTreeTest extends utest.Test {
}
function testParse() {
var tree = StoryNode.FromAST(new Parser().parseFile("examples/diverts/main.hank"));
var tree = StoryNode.FromAST(new Parser().parseFile("examples/diverts/main.hank", files));
HankAssert.isSome(tree.resolve("start"));
HankAssert.isSome(tree.resolve("three"));

View File

@@ -1,10 +1,12 @@
package tests.main;
import utest.Test;
import hank.StoryTestCase;
import hank.LogUtil;
@:build(hank.FileLoadingMacro.build(["examples/"]))
class Examples extends Test {
public static function main() {
trace('Testing examples for target ${LogUtil.currentTarget()}');
utest.UTest.run([new StoryTestCase("examples"
#if !sys
, files

View File

@@ -1,9 +1,11 @@
package tests.main;
import utest.Test;
import hank.StoryTestCase;
import hank.LogUtil;
class Internals extends Test {
public static function main() {
trace('Testing internals for target ${LogUtil.currentTarget()}');
utest.UTest.run([new HInterfaceTest(), new HankBufferTest(), new ParserTest(), new StoryTreeTest(), new FileLoadingMacroTest()]);
}
}