Adds verbose output to Assert-Equivalent and fixes two bugs in collection comparison.
When comparing collections we go through each item in Expected and compare it for equivalence with every item in Actual. When the item is found, we take note of the index in actual so we dont compare them further. This way we are able to compare a: (1,1,2) to e:(1,1,2) as equivalent, but a: (1,1,2), e:(1,2,2) as not equivalent. Without taking the already matched items out of consideration we would be linking one item from expected to multiple items in actual, or vice versa. - but in the loop where this was happening it did not return right after a match was found, so every item in the collection was marked as taken, and none were left for the next iteration. Making the assertion report non-equivalence even though the collections are equivalent. To solve this I simply break out of the loop as soon as I find an item.
Now you might ask why ($null, $null) did not fail then? There was another bug. When deciding whether or not the collections are equivalent I we look at the collection of items that were not found, but in case we did not find a single null, we cast @($null) to bool which is false, so it seems that all items were found (0 items were not found), which is not true. so instead of depending on the rules of coalescing to bool I am taking note that there is some difference when the branch of logic is reached, which results in ($null, $null) failng "correctly" when the above bug is present.
Adds verbose output to Assert-Equivalent and fixes two bugs in collection comparison.
When comparing collections we go through each item in Expected and compare it for equivalence with every item in Actual. When the item is found, we take note of the index in actual so we dont compare them further. This way we are able to compare a: (1,1,2) to e:(1,1,2) as equivalent, but a: (1,1,2), e:(1,2,2) as not equivalent. Without taking the already matched items out of consideration we would be linking one item from expected to multiple items in actual, or vice versa. - but in the loop where this was happening it did not return right after a match was found, so every item in the collection was marked as taken, and none were left for the next iteration. Making the assertion report non-equivalence even though the collections are equivalent. To solve this I simply break out of the loop as soon as I find an item.
Now you might ask why ($null, $null) did not fail then? There was another bug. When deciding whether or not the collections are equivalent I we look at the collection of items that were not found, but in case we did not find a single null, we cast @($null) to bool which is false, so it seems that all items were found (0 items were not found), which is not true. so instead of depending on the rules of coalescing to bool I am taking note that there is some difference when the branch of logic is reached, which results in ($null, $null) failng "correctly" when the above bug is present.
Fix #31