@testable import PureYAML import Testing /// A comment opens after white space, a tab as well as a space, so a `#` preceded by a tab ends a /// plain scalar and begins a trailing comment. A tab inside a plain scalar, with no `#` after it, /// stays part of the value, and a `#` glued directly to content (no white space) is content. @Suite("Plain scalar tab comment") struct PlainScalarTabCommentTests { @Test("A tab before a hash ends the scalar and starts a comment") func test_tabBeforeComment() throws { #expect(try PureYAML.parse("c: d\t#X\n") == .mapping(.init([ .init(key: "c", value: .string("d")), ]))) } @Test("A tab inside a plain scalar value is kept") func test_internalTabKept() throws { #expect(try PureYAML.parse("x: a\tb\n") == .mapping(.init([ .init(key: "x", value: .string("a\tb")), ]))) } @Test("A hash glued to content with no white space stays content") func test_hashWithoutWhitespaceIsContent() throws { #expect(try PureYAML.parse("c: d#X\n") == .mapping(.init([ .init(key: "c", value: .string("d#X")), ]))) } @Test("A space before a hash still ends the scalar") func test_spaceBeforeCommentUnchanged() throws { #expect(try PureYAML.parse("c: d #X\n") == .mapping(.init([ .init(key: "c", value: .string("d")), ]))) } }