@@ -67,6 +67,22 @@ Describe 'Export-Yaml' {
6767 $result | Should - Be @ (' one' , ' two' )
6868 }
6969
70+ It ' preserves an explicit one-element array as a sequence' {
71+ $path = Join-Path $TestDrive ' one-element-array.yaml'
72+
73+ Export-Yaml - InputObject @ (42 ) - Path $path
74+
75+ [System.IO.File ]::ReadAllText($path ) | Should - Be " - 42`n "
76+ }
77+
78+ It ' preserves an explicit empty array as an empty sequence' {
79+ $path = Join-Path $TestDrive ' empty-array.yaml'
80+
81+ Export-Yaml - InputObject @ () - Path $path
82+
83+ [System.IO.File ]::ReadAllText($path ) | Should - Be " []`n "
84+ }
85+
7086 It ' collects multiple pipeline records into one sequence' {
7187 $path = Join-Path $TestDrive ' pipeline.yaml'
7288
@@ -76,6 +92,30 @@ Describe 'Export-Yaml' {
7692 $result | Should - Be @ (' one' , ' two' , ' three' )
7793 }
7894
95+ It ' distinguishes one nested pipeline record from multiple records' {
96+ $singlePath = Join-Path $TestDrive ' single-nested-record.yaml'
97+ $multiplePath = Join-Path $TestDrive ' multiple-nested-records.yaml'
98+ $firstRecord = [object []]::new(1 )
99+ $firstRecord [0 ] = [object []] @ (1 , 2 )
100+ $secondRecord = [object []]::new(1 )
101+ $secondRecord [0 ] = [object []] @ (3 , 4 )
102+
103+ Write-Output - InputObject $firstRecord - NoEnumerate |
104+ Export-Yaml - Path $singlePath
105+ & {
106+ Write-Output - InputObject $firstRecord - NoEnumerate
107+ Write-Output - InputObject $secondRecord - NoEnumerate
108+ } | Export-Yaml - Path $multiplePath
109+
110+ $singleExpected = ConvertTo-Yaml - InputObject $firstRecord
111+ $multipleExpected = & {
112+ Write-Output - InputObject $firstRecord - NoEnumerate
113+ Write-Output - InputObject $secondRecord - NoEnumerate
114+ } | ConvertTo-Yaml
115+ [System.IO.File ]::ReadAllText($singlePath ) | Should - Be $singleExpected
116+ [System.IO.File ]::ReadAllText($multiplePath ) | Should - Be $multipleExpected
117+ }
118+
79119 It ' serializes an explicit null input' {
80120 $path = Join-Path $TestDrive ' null.yaml'
81121
0 commit comments