@testable import PureYAML import Testing /// An explicit block scalar indentation indicator (`|2`, `>1`) is the content indentation relative to /// the block scalar's parent node. For an inline mapping value (`- aaa: |2`) the parent is the /// mapping, which sits at an implicit indentation off the main stack, so the indicator is measured /// from there. A direct sequence item (`- |1`) has no such parent and keeps the sequence's own level. @Suite("Block scalar indent indicator") struct BlockScalarIndentIndicatorTests { @Test("An indicator on an inline mapping value is relative to the mapping indent") func test_inlineMappingValue() throws { #expect(try PureYAML.parse("- aaa: |2\n xxx\n bbb: |\n xxx\n") == .sequence([ .mapping(.init([ .init(key: "aaa", value: .string("xxx\n")), .init(key: "bbb", value: .string("xxx\n")), ])), ])) } @Test("An indicator on a root mapping value is relative to the root") func test_rootMappingValue() throws { #expect(try PureYAML.parse("aaa: |2\n xxx\n") == .mapping(.init([ .init(key: "aaa", value: .string("xxx\n")), ]))) } @Test("An indicator on a direct sequence item keeps the sequence base") func test_sequenceItem() throws { // `|1` over ` explicit` (indent 2) strips one space at the sequence's own base, not three. #expect(try PureYAML.parse("- |1\n explicit\n") == .sequence([.string(" explicit\n")])) } }