From 941c3f948ad3bb97421d1a0fe1af2b6e64b76e19 Mon Sep 17 00:00:00 2001 From: Mihaela M Date: Mon, 29 Jun 2026 07:23:57 +0200 Subject: [PATCH] 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. --- Tests/InlineBlockSequenceValueTests.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Tests/InlineBlockSequenceValueTests.swift b/Tests/InlineBlockSequenceValueTests.swift index 528e298..600d986 100644 --- a/Tests/InlineBlockSequenceValueTests.swift +++ b/Tests/InlineBlockSequenceValueTests.swift @@ -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")])), + ]))) } }