-
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
Consider adding NullableRef and NullableValue wrappers #610
Comments
Yeah, I felt like the default has changed to "nulls are opt-in" in recent years, in F# since the beginning and in C# more recently. You can write a string generator that also generates nulls in whatever frequency you'd like. |
Thank you, I was able to figure out the following which fails the test with [Property]
public Property Test() {
// Gen<string?> NullableString() => Gen.Frequency((1, Gen.Constant<string?>(null)), (7, ArbMap.Default.GeneratorFor<string?>()));
Gen<string?> NullableString() => Gen.OrNull(ArbMap.Default.GeneratorFor<string?>());
return Prop.ForAll(NullableString().ToArbitrary(), s => {
return (s != null).Collect(s);
});
} I see something in the source called |
that's in reference to https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1.value?view=net-6.0 i.e. for nullable value types. So it won't help with strings. Should probably have NullableRef and NullableValue at this point... The idea to use this would be:
|
OK, thanks for all the help! Not sure if you want this issue open for "NullableRef and NullableValue", so feel free to close if not. |
The code below does not fail in v3. This seems similar to #30 (v2 does still return nulls).
Is this an expected change for v3? What is the recommended way to have nulls mixed in?
The text was updated successfully, but these errors were encountered: