Content after a '...' document-end marker begins a new bare document, but the scanner rejected it as an unsupported multi-document stream and the parser expected the document to end at the marker. A stream like '--- scalar / ... / key: value' or 'a / ... / b' is two documents. The scanner now reopens the stream when content follows '...', and parseDocument returns at a '...' so the outer stream loop parses the next document, bare or marked. A trailing '...' with nothing after it still leaves a single document. The single-document composer still rejects a multi-document stream, so 'parse' is unchanged. Two tests that asserted content after '...' is an error are corrected, since the construct is valid per the grammar and the official test-suite. Measured against the official YAML test-suite, parse-level conformance rises from 288/333 (86.5%) to 289/333 (86.8%) with no regression.
22 lines
897 B
Swift
22 lines
897 B
Swift
@testable import PureYAML
|
|
import Testing
|
|
|
|
@Suite("Bare documents after a document-end marker")
|
|
struct BareDocumentAfterEndTests {
|
|
@Test("Content after `...` is a new bare document")
|
|
func test_bareDocumentAfterEnd() throws {
|
|
// A document started with `---`, ended with `...`, then a bare document follows.
|
|
let documents = try PureYAML.parseStream("---\nscalar1\n...\nkey: value\n")
|
|
#expect(documents.count == 2)
|
|
#expect(documents[0].value == .string("scalar1"))
|
|
#expect(documents[1].value == .mapping(.init([.init(key: "key", value: .string("value"))])))
|
|
}
|
|
|
|
@Test("A `...` with nothing after it leaves a single document")
|
|
func test_trailingEndMarkerLeavesOneDocument() throws {
|
|
let documents = try PureYAML.parseStream("a\n...\n")
|
|
#expect(documents.count == 1)
|
|
#expect(documents[0].value == .string("a"))
|
|
}
|
|
}
|