@testable import PureYAML import Testing /// A flow mapping entry may omit its `:` value indicator, in which case the key maps to null: `{ a }` /// and `{ a, b }` are flow sets. Entries with and without values mix freely, and a key without a value /// may itself span lines (`{ multi`/`line, a: b}`). @Suite("Flow mapping no value") struct FlowMappingNoValueTests { @Test("A single key with no value maps to null") func test_singleKey() throws { #expect(try PureYAML.parse("{ a }\n") == .mapping(.init([ .init(key: "a", value: .null), ]))) } @Test("Several keys with no value form a set") func test_set() throws { #expect(try PureYAML.parse("{ a, b }\n") == .mapping(.init([ .init(key: "a", value: .null), .init(key: "b", value: .null), ]))) } @Test("Valued and valueless entries mix") func test_mixed() throws { #expect(try PureYAML.parse("{ a: 1, b }\n") == .mapping(.init([ .init(key: "a", value: .int(1)), .init(key: "b", value: .null), ]))) } @Test("A valueless key may span lines") func test_multilineValuelessKey() throws { #expect(try PureYAML.parse("{ multi\n line, a: b}\n") == .mapping(.init([ .init(key: "multi line", value: .null), .init(key: "a", value: .string("b")), ]))) } }