PureYAML/Tests/MultilineImplicitKeyTests.swift
Mihaela Mihaljevic a8950e118c Merge conformance/yaml-test-suite-gaps: the libyaml port becomes the engine on main
The ported engine wins every conflict: main's post-fork patches to the
hand-rolled Scanner and TokenEventParser land on deleted files and are
dropped; their behaviors are carried by the port and guarded by the
whole-suite conformance gate (402/402 passing).

Merge adaptations, all gates green (style, namespacing, forbidden
patterns, changelog, roadmap, swiftformat, swiftlint strict, build,
full test suite, whole-suite conformance sweep):

- PureYAMLJSON representability rules move onto the Check algebra,
  replacing the retired legacy Rule type.
- The permissive tag-handle pre-pass is removed; the port rejects an
  undefined handle at parse time (suite case QLJ7) and the validation
  report carries it as a parse diagnostic.
- EventStreamComposer's nested types split one-per-file per the
  namespacing gate.
- Tests pinned to old-engine behavior were re-verified against the
  reference and updated: libyaml rejects an explicit-key continuation
  ending at a value colon, and suite case QB6E requires rejecting a
  quoted continuation at column 0.
- CHANGELOG unreleased entries from both lines are preserved in two
  groups with a provenance note.

Closes #1, closes #3
2026-07-05 00:23:48 +02:00

27 lines
1.1 KiB
Swift

@testable import PureYAML
import Testing
@Suite("Multiline implicit keys")
struct MultilineImplicitKeyTests {
@Test("A quoted block implicit key that spans lines is rejected", arguments: [
"\"c\n d\": 1\n", // a double-quoted key across two lines
"'c\n d': 1\n", // a single-quoted key across two lines
])
func test_multilineBlockKeyRejected(_ yaml: String) throws {
#expect(throws: PureYAML.Parsing.ParseError.self) {
try PureYAML.parse(yaml)
}
}
@Test("Single-line keys, multiline values, flow keys, and explicit keys stay valid", arguments: [
"\"a b\": 1\n", // a single-line quoted key
"k: \"a\n b\"\n", // a multiline quoted value (not a key), continuation indented
"{ \"a\nb\": 1 }\n", // a flow mapping key may span lines
"---\n- { \"multi\n line\": value}\n", // a multiline flow key inside a sequence
"? \"a\n b\"\n: v\n", // an explicit key may span lines, continuation indented
])
func test_validQuotedKeysAndValues(_ yaml: String) throws {
_ = try PureYAML.parse(yaml)
}
}