Skip to content

Commit

Permalink
Merge pull request #165 from gabriel-samfira/fix-casting-zero-as-bigint
Browse files Browse the repository at this point in the history
Fix broken if comparison
  • Loading branch information
gabriel-samfira authored Dec 16, 2024
2 parents fca7cce + 47a2875 commit 352d6b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Tests/powershell-yaml.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ wishlist:
scientificNotationInt: 1e+3
scientificNotationBigInt: 1e+40
intWithTag: !!int "42"
zeroIntWithTag: !!int "0"
zeroIntWithoutTag: 0
scientificNotationIntWithTag: !!int "1e+3"
price : 55.34
total: 4443.52
Expand Down Expand Up @@ -302,6 +304,8 @@ bools:
scientificNotationInt = [int32]1000
scientificNotationBigInt = [System.Numerics.BigInteger]::Parse("10000000000000000000000000000000000000000")
intWithTag = 42
zeroIntWithTag = 0
zeroIntWithoutTag = 0
scientificNotationIntWithTag = 1000
}
);
Expand Down Expand Up @@ -351,6 +355,10 @@ bools:
$product['aStringTatLooksLikeAFloat'] | Should -BeOfType ([string])
$product['aStringThatLooksLikeAnInt'] | Should -Be $expectedProduct['aStringThatLooksLikeAnInt']
$product['aStringThatLooksLikeAnInt'] | Should -BeOfType ([string])
$product['zeroIntWithTag'] | Should -Be $expectedProduct['zeroIntWithTag']
$product['zeroIntWithTag'] | Should -BeOfType ([int32])
$product['zeroIntWithoutTag'] | Should -Be $expectedProduct['zeroIntWithoutTag']
$product['zeroIntWithoutTag'] | Should -BeOfType ([int32])
$product['scientificNotationInt'] | Should -Be $expectedProduct['scientificNotationInt']
$product['scientificNotationInt'] | Should -BeOfType ([int32])
$product['scientificNotationBigInt'] | Should -Be $expectedProduct['scientificNotationBigInt']
Expand Down
4 changes: 2 additions & 2 deletions powershell-yaml.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function Convert-ValueToProperType {
}
foreach ($i in $intTypes) {
$asIntType = $parsedValue -as $i
if($asIntType) {
if($null -ne $asIntType) {
return $asIntType
}
}
Expand Down Expand Up @@ -212,7 +212,7 @@ function Convert-ValueToProperType {
$types = @([int], [long])
foreach($i in $types){
$asType = $parsedValue -as $i
if($asType) {
if($null -ne $asType) {
return $asType
}
}
Expand Down

0 comments on commit 352d6b0

Please sign in to comment.