This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
recursiveEquality $test $expected | Should -BeTrue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# modified from https://github.com/chriskuech/functional | |
function recursiveEquality($a, $b) { | |
# recursive step for arrays | |
if ($a -is [array] -and $b -is [array]) { | |
if ($a.Count -ne $b.Count) { | |
return $false | |
} | |
$inequalIndexes = 0..($a.Count - 1) | ? { -not (recursiveEquality $a[$_] $b[$_]) } | |
return $inequalIndexes.Count -eq 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$myObj = @{} | |
$myObj["a"] = $myObj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ # depth 1 | |
a = @( # depth 2 | |
1, | |
@{ # depth 3 | |
b = 2 | |
} | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Assert-ArrayEquality($test, $expected) { | |
$test | Should -HaveCount $expected.Count | |
0..($test.Count - 1) | % {$test[$_] | Should -Be $expected[$_]} | |
} | |
function Assert-HashtableEquality($test, $expected) { | |
$test.Keys | Should -HaveCount $expected.Keys.Count | |
$test.Keys | % {$test[$_] | Should -Be $expected[$_]} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$test | Should -HaveCount $expected.Count | |
$test[3] | Should -Be $expected[3] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> $a, $b = @{}, @{} | |
PS> $a -eq $a | |
True | |
PS> $a -eq $b | |
False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> @{} | Should -Be @{} | |
Expected System.Collections.Hashtable, but got System.Collections.Hashtable. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> @{} -eq @{} | |
False | |
PS> [PSCustomObject]@{} -eq [PSCustomObject]@{} | |
False | |
PS> @() -eq @() # doesn't even output True or False | |
PS> @(1, 2, 3) -eq @(1, 2, 3) # doesn't even output True or False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS> 4 -eq 4 | |
True | |
PS> "joe estevez" -eq "emilio estevez" | |
False | |
PS> "Joe Estevez" -eq "joe estevez" | |
True |