@testable import PureYAML import Testing /// A plain scalar key in a flow collection may span lines: the continuation folds across the line /// break even when the line ends at the `:` value indicator, since a flow key, unlike a block implicit /// key, is allowed to be multi-line. A block implicit key still stops before such a `:`, treating the /// next line as a new key. @Suite("Multiline flow key") struct MultilineFlowKeyTests { @Test("A flow mapping key folds across a line break") func test_flowMappingKey() throws { #expect(try PureYAML.parse("{ multi\n line: v }\n") == .mapping(.init([ .init(key: "multi line", value: .string("v")), ]))) } @Test("A flow sequence plain element still folds, unchanged") func test_flowSequenceElement() throws { #expect(try PureYAML.parse("[ multi\n line ]\n") == .sequence([.string("multi line")])) } @Test("An ordinary single-line flow mapping is unchanged") func test_singleLineFlowMapping() throws { #expect(try PureYAML.parse("{a: 1, b: 2}\n") == .mapping(.init([ .init(key: "a", value: .int(1)), .init(key: "b", value: .int(2)), ]))) } @Test("A block implicit key does not span lines") func test_blockImplicitKeyDoesNotSpan() { // `foo` then `bar: baz` is a value and a new key, not the key `foo bar`, so this is an error. #expect(throws: PureYAML.Parsing.ParseError.self) { try PureYAML.parse("foo\n bar: baz\n") } } }