@testable import PureYAML import Testing /// A document-end marker (`...`) may appear repeatedly: once a document is closed, a further `...` /// (with only comments or blank lines since the last one) ends nothing and is a no-op, rather than /// being rejected. Content other than a comment after such a marker is still an error. @Suite("Repeated document end") struct RepeatedDocumentEndTests { @Test("A second `...` after a closed document, separated by a comment, is a no-op") func test_repeatedMarkerIsNoOp() throws { let documents = try PureYAML.parseStream("a\n...\n# comment\n...\nb\n").map(\.value) #expect(documents == [.string("a"), .string("b")]) } @Test("A comment-only region between two `...` markers contributes no document") func test_commentOnlyBetweenMarkers() throws { // Mirrors suite case M7A3: a bare document, then `...`, a comment, a repeated `...`, and a // root block scalar as the next document. let yaml = "Bare\ndocument\n...\n# No document\n...\n|\n%!PS-Adobe-2.0 # Not the first line\n" let documents = try PureYAML.parseStream(yaml).map(\.value) #expect(documents == [.string("Bare document"), .string("%!PS-Adobe-2.0 # Not the first line\n")]) } @Test("Real content after a repeated `...` marker is still rejected") func test_contentAfterRepeatedMarkerRejected() { #expect(throws: PureYAML.Parsing.ParseError.self) { _ = try PureYAML.parseStream("a\n...\n... x\n") } } }