@testable import PureYAML import Testing @Suite("Block sequence as an inline mapping value") struct InlineBlockSequenceValueTests { @Test("A block sequence on the same line as an implicit key's `:` is rejected") func test_inlineBlockSequenceValueRejected() throws { #expect(throws: PureYAML.Parsing.ParseError.self) { try PureYAML.parse("key: - a\n - b\n") } } @Test("Block sequences positioned correctly, and look-alikes, stay valid", arguments: [ "key:\n - a\n - b\n", // sequence indented on the next line "key:\n- a\n- b\n", // sequence at the key's indentation "- - a\n", // a nested block sequence "- key: value\n", // a sequence item that is a mapping "key: [a, b]\n", // a flow sequence value "key: -1\n", // a negative number, not a block entry "a: b - c\n", // a dash inside a plain scalar value ]) func test_validSequencesStillParse(_ yaml: String) throws { _ = try PureYAML.parse(yaml) } @Test("An explicit key's value on its own `:` line is not rejected as inline") func test_explicitKeyCompactSequenceValueNotRejected() 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") } }