@testable import PureYAML import Testing @Suite("Block scalar leading blank indentation") struct BlockScalarLeadingBlankTests { @Test("A leading blank line more indented than the content is rejected", arguments: [ "block scalar: >\n \n \n \n invalid\n", // blanks at 2,3 spaces over content at 1 "---\nblock scalar: |\n \n more spaces\n are invalid\n", // a 5-space blank over content at 2 ]) func test_overIndentedLeadingBlankRejected(_ yaml: String) throws { #expect(throws: PureYAML.Parsing.ParseError.self) { try PureYAML.parse(yaml) } } @Test("Leading blanks within the content indent, including a tab, stay valid") func test_validLeadingBlanks() throws { #expect(try PureYAML.parse("x: |\n\n content\n") == .mapping(.init([ .init(key: "x", value: .string("\ncontent\n")), ]))) #expect(try PureYAML.parse("x: |\n \n content\n") == .mapping(.init([ .init(key: "x", value: .string("\ncontent\n")), ]))) // A tab on a blank line is not indentation, so `␣\t` is one space, not a tab-stop jump. _ = try PureYAML.parse("- >\n \t\n detected\n") } }