Fill the highest-value coverage gaps found in the Codable bridge and parser: the full integer-width decode ladder and per-width out-of-range errors, Float round-trip, NaN equality and hash consistency (the bespoke nan == nan invariant), unkeyed decodeNil false-branch and nested-index mismatch, and the previously untested expectedNode, unterminated flow mapping, explicit block-scalar under-indent, and buffered invalid-merge error paths.
38 lines
1.5 KiB
Swift
38 lines
1.5 KiB
Swift
@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)
|
|
}
|
|
}
|