You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some tests using tasty-golden + ediffGolden with data structures containing HashMap values. These tests work locally, but fail on CI due to the CI server generating Expr values for the HashMap values with the items in a different order than was captured in the golden snapshot.
Analysis
ediffGolden assumes (?) that a == b implies toExpr a == toExpr b.
However, the ToExpr instance for HashMap (source) captures the raw ordering returned by HM.toList, which isn't reliable across platforms (or in the presence of collisions and insert reordering), so the above property doesn't hold.
(This also affects the ToExpr instance of HashSet.)
Workaround
I'm already using a Expr construction in the affected code, so for the time being, I'm just using this variation of toExpr for HashMap sorts the items:
toExpr_HM:: (ToExprk, ToExprv, Ordk, Ordv) =>HM.HashMapkv->Expr
toExpr_HM x =App"HM.fromList" [ toExpr $ sort $HM.toList x ]
The text was updated successfully, but these errors were encountered:
Problem
I have some tests using
tasty-golden
+ediffGolden
with data structures containingHashMap
values. These tests work locally, but fail on CI due to the CI server generatingExpr
values for theHashMap
values with the items in a different order than was captured in the golden snapshot.Analysis
ediffGolden
assumes (?) thata == b
impliestoExpr a == toExpr b
.However, the
ToExpr
instance forHashMap
(source) captures the raw ordering returned byHM.toList
, which isn't reliable across platforms (or in the presence of collisions and insert reordering), so the above property doesn't hold.(This also affects the
ToExpr
instance ofHashSet
.)Workaround
I'm already using a
Expr
construction in the affected code, so for the time being, I'm just using this variation oftoExpr
forHashMap
sorts the items:The text was updated successfully, but these errors were encountered: