Empty documents always contain an empty scalar

This commit is contained in:
Felix Krause 2016-11-30 21:58:46 +01:00
parent 294fc875bd
commit 44ca31b1e2
2 changed files with 6 additions and 13 deletions

View File

@ -103,7 +103,7 @@ proc testsFor(path: string, root: bool = true, titlePrefix: string = ""):
NimNode {.compileTime.} =
result = newStmtList()
let
baseDir = staticExec("pwd")
baseDir = parentDir(staticExec("pwd"))
nimPathRaw = staticExec("which nim")
nimPath = if nimPathRaw[0] == '/': nimPathRaw else: baseDir / nimPathRaw
title = titlePrefix & slurp(baseDir / path / "title").splitLines()[0]
@ -128,4 +128,4 @@ proc testsFor(path: string, root: bool = true, titlePrefix: string = ""):
macro genTests(): untyped = testsFor("doc/snippets/quickstart")
genTests()
genTests()

View File

@ -429,21 +429,14 @@ proc endLevel(c: ParserContext, e: var YamlStreamEvent):
LevelEndResult =
result = lerOne
case c.level.kind
of fplSequence:
e = endSeqEvent()
of fplMapKey:
e = endMapEvent()
of fplSequence: e = endSeqEvent()
of fplMapKey: e = endMapEvent()
of fplMapValue, fplSinglePairValue:
e = emptyScalar(c)
c.level.kind = fplMapKey
result = lerAdditionalMapEnd
of fplUnknown:
if c.ancestry.len > 1:
e = emptyScalar(c) # don't yield scalar for empty doc
else:
result = lerNothing
of fplDocument:
e = endDocEvent()
of fplUnknown: e = emptyScalar(c)
of fplDocument: e = endDocEvent()
of fplSinglePairKey:
internalError("Unexpected level kind: " & $c.level.kind)