diff options
Diffstat (limited to 'src/main/scala/com/iinteractive/test/tap/Parser.scala')
-rw-r--r-- | src/main/scala/com/iinteractive/test/tap/Parser.scala | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/main/scala/com/iinteractive/test/tap/Parser.scala b/src/main/scala/com/iinteractive/test/tap/Parser.scala index c66b1a7..31a6b6f 100644 --- a/src/main/scala/com/iinteractive/test/tap/Parser.scala +++ b/src/main/scala/com/iinteractive/test/tap/Parser.scala @@ -111,18 +111,25 @@ class Parser private ( private def subtest: Parser[TAPResult] = LineParser("subtest") { in => - // can't just return the result directly, because it's of a different - // type (the path dependent type associated with the new Parser - // instance we create here, rather than the path dependent type - // associated with this) - val subParser = new TAPParser( - e => (), - in.first.indent - ) - subParser.tap(in) match { - case subParser.Success(p, rest) => Success(p, rest) - case subParser.Failure(m, rest) => Failure(m, rest) - case subParser.Error(m, rest) => Error(m, rest) + val newIndent = in.first.indent + + if (newIndent.startsWith(indent) && newIndent != indent) { + // can't just return the result directly, because it's of a + // different type (the path dependent type associated with the new + // Parser instance we create here, rather than the path dependent + // type associated with this) + val subParser = new TAPParser( + e => (), + newIndent + ) + subParser.tap(in) match { + case subParser.Success(p, rest) => Success(p, rest) + case subParser.Failure(m, rest) => Failure(m, rest) + case subParser.Error(m, rest) => Error(m, rest) + } + } + else { + Failure("not a subtest", in) } } |