@testable import PureYAML import Testing /// In a folded block scalar (`>`), a single line break between two non-more-indented lines folds to a /// space, and a blank run of N lines between them yields N line breaks (the fold is absorbed). Next to /// a more-indented line nothing folds, so the absorbed break survives and the run yields N+1 breaks; /// more-indented lines keep their own line breaks. @Suite("Folded scalar blank lines") struct FoldedScalarBlankLineTests { @Test("A blank line next to a more-indented line keeps both breaks") func test_blankNextToMoreIndented() throws { let input = ">\n Sammy Sosa completed another\n fine season with great stats.\n\n" + " 63 Home Runs\n 0.288 Batting Average\n\n What a year!\n" #expect(try PureYAML.parse(input) == .string( "Sammy Sosa completed another fine season with great stats.\n\n" + " 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n", )) } @Test("A blank line between non-more-indented lines folds one break away") func test_blankBetweenPlainLines() throws { // `folded`+`line` fold to a space; the blank yields one break; the more-indented bullets keep // their breaks and the blank around them keeps both. let input = ">\n\n folded\n line\n\n next\n line\n * bullet\n\n" + " * list\n * lines\n\n last\n line\n\n# Comment\n" #expect(try PureYAML.parse(input) == .string( "\nfolded line\nnext line\n * bullet\n\n * list\n * lines\n\nlast line\n", )) } @Test("A plain folded scalar with no blank lines is unchanged") func test_noBlankLines() throws { #expect(try PureYAML.parse(">\n folded\n text\n") == .string("folded text\n")) } }