@testable import PureYAML import Testing /// A block scalar whose only lines are blank still carries those blank lines through chomping at /// stream end. Keep (`|+` / `>+`) preserves them as line breaks, while clip (default) and strip /// (`|-`) trim them away, so an empty keep scalar over one blank line is a single line break. @Suite("Empty block scalar chomping") struct EmptyBlockScalarChompingTests { @Test("Keep chomping over a single blank line yields one line break") func test_keepOneBlank() throws { #expect(try PureYAML.parse("x: |+\n\n") == .mapping(.init([ .init(key: "x", value: .string("\n")), ]))) } @Test("Keep chomping over two blank lines yields two line breaks") func test_keepTwoBlanks() throws { #expect(try PureYAML.parse("x: |+\n\n\n") == .mapping(.init([ .init(key: "x", value: .string("\n\n")), ]))) } @Test("Clip and strip on empty content yield the empty string") func test_clipAndStripEmpty() throws { #expect(try PureYAML.parse("x: |\n\n") == .mapping(.init([ .init(key: "x", value: .string("")), ]))) #expect(try PureYAML.parse("x: >-\n\n") == .mapping(.init([ .init(key: "x", value: .string("")), ]))) } @Test("Mixed chomping keys at stream end each chomp their empty content") func test_mixedChompingAtStreamEnd() throws { #expect(try PureYAML.parse("strip: >-\n\nclip: >\n\nkeep: |+\n\n") == .mapping(.init([ .init(key: "strip", value: .string("")), .init(key: "clip", value: .string("")), .init(key: "keep", value: .string("\n")), ]))) } }