test(parsing): assert an explicit-key compact sequence's value
The explicit-key compact block-sequence case (`? k\n: - a\n - b\n`) was only
asserted to parse without error, with a comment deferring its value because the
two entries used to fold into a single `"a - b"` scalar. That defect is fixed:
it now parses to `{k: ["a", "b"]}`. Strengthen the test to a value-level
assertion so the correct tree is locked against regression, and drop the
obsolete carve-out comment.
This commit is contained in:
parent
5a3bf6518c
commit
941c3f948a
@ -23,12 +23,14 @@ struct InlineBlockSequenceValueTests {
|
||||
_ = try PureYAML.parse(yaml)
|
||||
}
|
||||
|
||||
@Test("An explicit key's value on its own `:` line is not rejected as inline")
|
||||
func test_explicitKeyCompactSequenceValueNotRejected() throws {
|
||||
@Test("An explicit key's compact block-sequence value parses to its two distinct items")
|
||||
func test_explicitKeyCompactSequenceValue() throws {
|
||||
// The `:` opens the line, so it is an explicit-key value indicator and the compact sequence
|
||||
// after it is allowed: the reject above is specific to an implicit key. The element folding
|
||||
// of an explicit-key compact sequence is a separate, pre-existing concern, so this asserts
|
||||
// only that the construct still parses rather than its exact value.
|
||||
_ = try PureYAML.parse("? k\n: - a\n - b\n")
|
||||
// after it is a block sequence under `k`: the implicit-key reject above does not apply. The
|
||||
// two entries stay distinct items rather than folding into a single `"a - b"` scalar.
|
||||
let value = try PureYAML.parse("? k\n: - a\n - b\n")
|
||||
#expect(value == .mapping(.init([
|
||||
.init(key: "k", value: .sequence([.string("a"), .string("b")])),
|
||||
])))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user