-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The type System.IComparable is not handled automatically by FsCheck #443
Comments
I think the following code produces a generator, but I was trying it on Expecto which does not support registering a type generator, so I still got the error message from tests.
I'll try to create a PR soon. |
I’m not convinced it’s a good idea to add this. What is the concrete use case? Wouldn’t it be simpler to generate a concrete type that you know is comparable eg |
Here's the concrete use case: I'm converting tests in this project from Nunit to Expecto, at the same time I upgraded F# support from 4.0. The nunit/fscheck tests passed with System.IComparable. But amongst updated F#, different testing framework, and more recent version of FsCheck, it's hard to know exactly why the tests now fail. I could just write equivalent tests without System.IComparable. I am not the original author of these tests. I would never have written them this way, however the original author thought things through in his own way, and it is desirable to keep a diversity of test styles in the project. My motivation has been only to convert, not alter any existing tests. |
There is a ComparableGenerator in that code that probably is not being registered with FsCheck after the move to expecto. I’m not super familiar with expecto, but hopefully, as with other extensions, you can tell it to add that to the default generators. For example, in FsCheck you can add that type via the Config, and in FsCheck.Xunit you can add it via PropertyAttribute. |
@kurtschelfthout Unfortunately register does not work in Expecto, and probably never will. I think there is an open issue. I'll look at trying to add it in the config, as you suggest. |
I'm trying to find some way to cons it to the arbitrary list in the config
but the build errors with "No constructors are available for the type 'ComparableGenerator<'a>". |
In the original code it doesn't look like the comparable generator is being registered either. I think you have problems that are wholly unrelated to FsCheck or Expecto. E.g. see the warnings in the build output: /home/travis/build/fsprojects/FSharpx.Collections/tests/FSharpx.Collections.Experimental.Tests/SkewBinomialHeapTest.fs(128,20): warning FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'T has been constrained to be type 'IComparable'. [/home/travis/build/fsprojects/FSharpx.Collections/tests/FSharpx.Collections.Experimental.Tests/FSharpx.Collections.Experimental.Tests.fsproj] |
Closing due to inactivity. |
Message returned trying to compare type System.IComparable
This would be a useful supported comparison.
The text was updated successfully, but these errors were encountered: