A tab is separation white space in YAML, so it follows the `:` mapping-value
indicator exactly as a space does. isMappingValueBoundary (flow) and
isBlockMappingValueBoundary (block) accepted only a space, line break, comma,
or closing bracket, so `foo:\tbar` folded into the plain scalar `foo:\tbar`
instead of the mapping `{foo: bar}`.
Accept a tab in both. A `:` with no following white space (`foo:bar`) is still
plain scalar content, and the symmetric counterpart for a tab after a leading
indicator landed in the previous change.
Raises yaml-test-suite parse-level to 300/333 (90.1%) with the should-error
rejection rate unchanged. 433 tests pass.
35 lines
1.3 KiB
Swift
35 lines
1.3 KiB
Swift
@testable import PureYAML
|
|
import Testing
|
|
|
|
/// A tab is separation white space in YAML, so it follows the `:` mapping-value indicator as a space
|
|
/// does, in both block and flow context. A `:` with no following white space at all stays plain
|
|
/// scalar content (`foo:bar`), unchanged.
|
|
@Suite("Mapping value tab boundary")
|
|
struct MappingValueTabBoundaryTests {
|
|
@Test("A block mapping value may follow the colon after a tab")
|
|
func test_blockValueTab() throws {
|
|
#expect(try PureYAML.parse("foo:\tbar\n") == .mapping(.init([
|
|
.init(key: "foo", value: .string("bar")),
|
|
])))
|
|
}
|
|
|
|
@Test("A block sequence item mapping accepts a tab after the colon")
|
|
func test_blockSequenceItemTab() throws {
|
|
#expect(try PureYAML.parse("- foo:\tbar\n") == .sequence([
|
|
.mapping(.init([.init(key: "foo", value: .string("bar"))])),
|
|
]))
|
|
}
|
|
|
|
@Test("A flow mapping value may follow the colon after a tab")
|
|
func test_flowValueTab() throws {
|
|
#expect(try PureYAML.parse("{a:\tb}\n") == .mapping(.init([
|
|
.init(key: "a", value: .string("b")),
|
|
])))
|
|
}
|
|
|
|
@Test("A colon with no following white space stays plain scalar content")
|
|
func test_colonWithoutWhitespaceUnchanged() throws {
|
|
#expect(try PureYAML.parse("foo:bar\n") == .string("foo:bar"))
|
|
}
|
|
}
|