@testable import PureYAML import Testing @Suite("Block scalar indentation edges") struct BlockScalarTrailingCommentTests { @Test("A comment less indented than block scalar content ends it without error") func test_lessIndentedTrailingCommentEndsBlockScalar() throws { // The `# comment` sits at column 2, below the content indent (column 3), so it ends the // block scalar and is an ordinary comment rather than driving a dedent onto an invalid // indentation level. #expect(try PureYAML.parse("|\n text\n # comment\n") == .string("text\n")) } @Test("An over-indented blank line keeps its surplus spaces as content") func test_overIndentedBlankLineKeepsSurplusSpaces() throws { // The middle line carries three spaces against a two-space content indent, so one surplus // space is preserved as the line's content instead of collapsing to empty. #expect(try PureYAML.parse("|\n a\n \n b\n") == .string("a\n \nb\n")) } @Test("A block scalar whose own content starts with '#' keeps it as literal text") func test_blockScalarContentStartingWithHash() throws { #expect(try PureYAML.parse("strip: |-\n # text\n") == .mapping(.init([ .init(key: "strip", value: .string("# text")), ]))) } }