@testable import PureYAML import Testing @Suite("Parsing Error Paths") struct ParsingErrorPathTests { @Test("A node property with no following node throws expectedNode") func test_danglingNodePropertyThrowsExpectedNode() { expectParseError("&anchor\n", .expectedNode(line: 1, column: 1)) expectParseError("root:\n key: &a\nother: 1\n", .expectedNode(line: 2, column: 8)) } @Test("An unterminated flow mapping throws at stream end") func test_unterminatedFlowMappingThrows() { expectParseError("x: {a: b", .unexpectedToken( expected: "flow entry or flow mapping end", actual: "streamEnd", line: 1, column: 9, )) } @Test("Block scalar content less indented than the explicit indicator throws") func test_explicitBlockScalarIndentationUnderIndentThrows() { expectParseError("k: |2\n a\n", .unexpectedIndentation(line: 2)) } @Test("Diagnostic validation reports an invalid merge value via the buffered composer") func test_diagnosticValidationRejectsInvalidMergeValue() { let report = PureYAML.diagnosticValidationReport("a: &x 1\nb:\n <<: *x\n", file: "merge.yaml") #expect(!report.isValid) #expect(report.diagnostics.count == 1) let diagnostic = report.diagnostics.first #expect(diagnostic?.kind == .parse) #expect(diagnostic?.code == "invalidMergeValue") #expect(diagnostic?.line == 3) } }