A document-start marker scan skipped the rest of the '---' line
unconditionally, so a root node written on that same line was discarded:
a block-scalar header ('--- >' / '--- |') was dropped and its body
mis-read as a plain scalar (folded to spaces, no trailing newline), and a
same-line plain or flow node was lost entirely. The document start now
skips only trailing spaces and leaves any real same-line content for the
parser; an empty rest-of-line or a comment is still consumed, and a node
on the line below the marker is unaffected. Document end ('...') still
takes no same-line node.
Measured against the official YAML test-suite, value-level conformance
rises from 130/170 (76.5%) to 135/169 (79.9%) with no regression.
Parse-level is unchanged: these documents already parsed, just to the
wrong tree, which only the value-level metric exposes.
21 lines
999 B
Swift
21 lines
999 B
Swift
@testable import PureYAML
|
|
import Testing
|
|
|
|
@Suite("Document marker root nodes")
|
|
struct DocumentMarkerNodeTests {
|
|
@Test("A block scalar header on the document-marker line is recognized, not discarded")
|
|
func test_blockScalarHeaderOnDocumentMarkerLine() throws {
|
|
// `--- >` / `--- |`: the marker scanner used to skip the rest of the line, dropping the
|
|
// block header so the body was mis-read as a plain scalar (folded, no trailing newline).
|
|
#expect(try PureYAML.parse("--- >\n a\n b\n") == .string("a b\n"))
|
|
#expect(try PureYAML.parse("--- |\n a\n b\n") == .string("a\nb\n"))
|
|
}
|
|
|
|
@Test("A scalar root node may begin on the document-marker line")
|
|
func test_scalarRootNodeOnDocumentMarkerLine() throws {
|
|
#expect(try PureYAML.parse("--- folded text\n") == .string("folded text"))
|
|
// A node still on its own line below the marker keeps working.
|
|
#expect(try PureYAML.parse("---\nplain text\n") == .string("plain text"))
|
|
}
|
|
}
|