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
In an earlier version, there used to be shouldEqual primitive that beahaved like y |> should equal x but statically required x and y to have the same type.
I find that extremely useful - I was using some untyped equal constraints and it quite regularly caused trouble where test would compile, but fail - when I changed some API.
Can we have this function (or some alternative) back?
The text was updated successfully, but these errors were encountered:
+1. It would be useful to support statically typed matchers in other cases too. I am currently trying the following (not tested yet, please point out errors):
let inline equalWithin t x =
let isInRange y = y <= x+t && y>= x-t
NHamcrest.CustomMatcher<_>(sprintf "%s with a tolerance of %s" (string x) (string t), fun v -> isInRange v)
let inline should' m expected actual = Xunit.Assert.That(actual, m expected)
This has the advantage of equalWithin working on any comparable type that supports -, + (including DateTime with TimeSpan tolerance). The current equalWithin only works with objects whose string representations parse as doubles.
In an earlier version, there used to be
shouldEqual
primitive that beahaved likey |> should equal x
but statically requiredx
andy
to have the same type.I find that extremely useful - I was using some untyped equal constraints and it quite regularly caused trouble where test would compile, but fail - when I changed some API.
Can we have this function (or some alternative) back?
The text was updated successfully, but these errors were encountered: