@testable import PureYAML import Testing /// A compact nested block sequence (`- - x`) carries no indent/dedent tokens, only block entries at /// their columns. A sequence collects sibling items only at its own column, so a later entry at a /// smaller column ends it and belongs to the enclosing sequence: `- - x` then `- - y` is `[[x], [y]]`, /// two outer items, not one outer item holding both. @Suite("Compact nested sequence") struct CompactNestedSequenceTests { @Test("Two compact nested entries are two outer items") func test_twoNestedItems() throws { #expect(try PureYAML.parse("- - x\n- - y\n") == .sequence([ .sequence([.string("x")]), .sequence([.string("y")]), ])) } @Test("Three levels of compact nesting separate at the outer column") func test_threeLevels() throws { #expect(try PureYAML.parse("- - - []\n- - - {}\n") == .sequence([ .sequence([.sequence([.sequence([])])]), .sequence([.sequence([.mapping(.init([]))])]), ])) } @Test("Entries at the same column stay one sequence") func test_sameColumnSiblings() throws { #expect(try PureYAML.parse("- - a\n - b\n") == .sequence([ .sequence([.string("a"), .string("b")]), ])) } @Test("A flat sequence is unchanged") func test_flatSequence() throws { #expect(try PureYAML.parse("- a\n- b\n") == .sequence([.string("a"), .string("b")])) } }