@testable import PureYAML import Testing /// An explicit key (`? foo`) may span lines: its plain scalar folds across the break, and a `:` on /// the last key line is the value indicator, not a new entry. Under an implicit key a continuation /// line ending at `:` is instead a new mapping key, so the scalar stops before it, unchanged. @Suite("Explicit key multiline fold") struct ExplicitKeyMultilineFoldTests { @Test("An explicit key folds a continuation line that ends at the value colon") func test_continuationEndingAtColon() throws { #expect(try PureYAML.parse("? foo\n bar : baz\n") == .mapping(.init([ .init(key: "foo bar", value: .string("baz")), ]))) } @Test("An explicit key with the colon on its own line still folds") func test_colonOnOwnLine() throws { #expect(try PureYAML.parse("? foo\n bar\n: baz\n") == .mapping(.init([ .init(key: "foo bar", value: .string("baz")), ]))) } @Test("An implicit key is unaffected: a continuation ending at a colon stays a new key") func test_implicitKeyUnchanged() throws { #expect(try PureYAML.parse("foo: bar\n") == .mapping(.init([ .init(key: "foo", value: .string("bar")), ]))) #expect(try PureYAML.parse("a: 1\nb: 2\n") == .mapping(.init([ .init(key: "a", value: .int(1)), .init(key: "b", value: .int(2)), ]))) } }