@testable import PureYAML import Testing /// A tab is separation white space in YAML (only indentation forbids a tab), so it ends a leading /// indicator exactly as a space does. A document marker, block entry, or explicit key followed by a /// tab is recognized as the indicator, not folded into a plain scalar. @Suite("Indicator tab boundary") struct IndicatorTabBoundaryTests { @Test("A document marker followed by a tab introduces an inline root scalar") func test_documentMarkerTab() throws { #expect(try PureYAML.parse("---\tscalar\n") == .string("scalar")) } @Test("A block entry indicator followed by a tab still starts a sequence item") func test_blockEntryTab() throws { #expect(try PureYAML.parse("-\titem\n") == .sequence([.string("item")])) } @Test("An explicit key indicator followed by a tab starts a mapping key with the tab stripped") func test_explicitKeyTab() throws { #expect(try PureYAML.parse("?\tkey\n: value\n") == .mapping(.init([ .init(key: "key", value: .string("value")), ]))) } @Test("A run of tabs between tokens is separation, not content") func test_multipleTabSeparation() throws { #expect(try PureYAML.parse("a:\t\tb\n") == .mapping(.init([ .init(key: "a", value: .string("b")), ]))) } @Test("A space after an indicator is unchanged") func test_spaceStillWorks() throws { #expect(try PureYAML.parse("--- scalar\n") == .string("scalar")) #expect(try PureYAML.parse("- item\n") == .sequence([.string("item")])) } }