Skip to content

Commit 9b34e90

Browse files
Keep serialization regressions analyzer-clean
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 992de6b commit 9b34e90

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

tests/ConvertTo-Yaml.Tests.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ namespace YamlTests
9595
}
9696

9797
function Get-YamlTestInfinitePipeline {
98+
<#
99+
.SYNOPSIS
100+
Produces an unbounded stream for resource-limit tests.
101+
#>
98102
param ([string] $Item = 'value')
99103

100104
while ($true) {
@@ -316,7 +320,8 @@ Describe 'ConvertTo-Yaml' {
316320
$atLimit = [System.Collections.Specialized.OrderedDictionary]::new()
317321
$atLimit.Add(('x' * 1024), 'value')
318322
$overLimit = [System.Collections.Specialized.OrderedDictionary]::new()
319-
$overLimit.Add(('😀' * 1025), [ordered]@{ nested = 'value' })
323+
$overLimitKey = [char]::ConvertFromUtf32(0x1F600) * 1025
324+
$overLimit.Add($overLimitKey, [ordered]@{ nested = 'value' })
320325

321326
$atLimitYaml = ConvertTo-Yaml -InputObject $atLimit
322327
$overLimitYaml = ConvertTo-Yaml -InputObject $overLimit
@@ -326,8 +331,8 @@ Describe 'ConvertTo-Yaml' {
326331
$overLimitYaml | Should -Match '^\? '
327332
$overLimitYaml | Should -Match '(?m)^: $'
328333
($overLimitYaml | Test-Yaml) | Should -BeTrue
329-
$roundTrip.Contains(('😀' * 1025)) | Should -BeTrue
330-
$roundTrip[('😀' * 1025)]['nested'] | Should -Be 'value'
334+
$roundTrip.Contains($overLimitKey) | Should -BeTrue
335+
$roundTrip[$overLimitKey]['nested'] | Should -Be 'value'
331336
}
332337

333338
It 'uses explicit keys when rendered collection keys exceed 1024 values' {
@@ -546,9 +551,11 @@ Describe 'ConvertTo-Yaml' {
546551
It 'stops infinite pipelines at the first oversized scalar' {
547552
$script:YamlTestPipelineCount = 0
548553

549-
{ Get-YamlTestInfinitePipeline -Item 'long' |
550-
ConvertTo-Yaml -MaxScalarLength 3 } |
551-
Should -Throw -ExpectedMessage '*configured limit of 3 characters*'
554+
$conversion = {
555+
Get-YamlTestInfinitePipeline -Item 'long' |
556+
ConvertTo-Yaml -MaxScalarLength 3
557+
}
558+
$conversion | Should -Throw -ExpectedMessage '*configured limit of 3 characters*'
552559
$script:YamlTestPipelineCount | Should -Be 1
553560
}
554561

0 commit comments

Comments
 (0)