@@ -185,4 +185,42 @@ Describe "Language Primitive Tests" -Tags "CI" {
185185 $test.TestHandlerReturnEnum () | Should - BeTrue
186186 $test.TestHandlerReturnObject () | Should - BeTrue
187187 }
188+
189+ It ' Handles large numbers with thousands separators that previously failed' {
190+ $formattedNumber = " 9223372036854775,807"
191+ $convertedValue = [System.Management.Automation.LanguagePrimitives ]::ConvertTo($formattedNumber , [bigint ])
192+ $convertedValue | Should - Be 9223372036854775807
193+ }
194+
195+ It ' Handles extremely large numbers to verify precision' {
196+ $formattedNumber = " 99999999999999999999999999999"
197+ $convertedValue = [System.Management.Automation.LanguagePrimitives ]::ConvertTo($formattedNumber , [bigint ])
198+ $convertedValue | Should - Be 99999999999999999999999999999
199+ }
200+
201+ It ' Parses mixed separators correctly' {
202+ $formattedNumber = " 1,0000,00"
203+ $convertedValue = [System.Management.Automation.LanguagePrimitives ]::ConvertTo($formattedNumber , [bigint ])
204+ $convertedValue | Should - Be 1000000
205+ }
206+
207+ It ' Parses a number string using the invariant culture, irrespective of the current culture' {
208+ $originalCulture = [cultureinfo ]::CurrentCulture
209+ try {
210+ [cultureinfo ]::CurrentCulture = [cultureinfo ]::GetCultureInfo(" de-DE" )
211+ $formattedNumber = " 1.000" # in de-DE this means 1000
212+ $convertedValue = [System.Management.Automation.LanguagePrimitives ]::ConvertTo($formattedNumber , [bigint ])
213+ # since [bigint] uses invariant culture, this will be parsed as 1
214+ $convertedValue | Should - Be 1
215+ }
216+ finally {
217+ [cultureinfo ]::CurrentCulture = $originalCulture
218+ }
219+ }
220+
221+ It ' Casts from floating-point number string to BigInteger using fallback' {
222+ $formattedNumber = " 1.2"
223+ $convertedValue = [System.Management.Automation.LanguagePrimitives ]::ConvertTo($formattedNumber , [bigint ])
224+ $convertedValue | Should - Be 1
225+ }
188226}
0 commit comments