DivideByZeroException in Gen.Choose
See original GitHub issueHello. I’m started trying to use FsCheck in C# Project. And I use simple example in test to generate any number from all range of int values:
[Test]
public void Test_MinMax()
{
var generator = Gen.Choose(int.MinValue, int.MaxValue);
foreach (var val in generator.Sample(10, 10))
Console.WriteLine(val);
}
And I got exception in test output in FsCheck:
System.DivideByZeroException : Attempted to divide by zero.
at FsCheck.Random.stdRange(Int32 l, Int32 h, StdGen rng)
at FsCheck.Random.range@74-1.Invoke(StdGen rng)
at FsCheck.Gen.Choose@178.Invoke(Int32 _arg1, StdGen r)
at FsCheck.Gen.sample@170[a](Int32 size, Gen`1 generator, Int32 i, StdGen seed, FSharpList`1 samples)
at FsCheck.Gen.Sample[a](Int32 size, Int32 n, Gen`1 generator)
at FsCheck.GenExtensions.Sample[a](Gen`1 generator, Int32 size, Int32 numberOfSamples)
Is this a bug? Or, i’m doing something wrong?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
DivideByZeroException Class (System)
The exception that is thrown when there is an attempt to divide an integral or Decimal value by zero.
Read more >C# DivideByZeroException won't execute [duplicate]
You are going to get divide by zero error only in case of integer input in c#. For double the desired output is...
Read more >.NET Exceptions - System.DivideByZeroException
DivideByZeroException is thrown when attempting to divide an integer or a decimal by zero. Normally divide by zero errors are pretty boring, but ......
Read more >C# - DivideByZeroException Exception Example
DivideByZeroException Exception. Here, we are demonstrating the divide by zero exception. We will divide a number by 0 then the program will ...
Read more >c# - Dividing two numbers then handle the divide by zero ...
but I want to check the possible errors so I used from try/catch for DivideByZeroException and all of the other errors by Exception...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
DoNotSize<T>
types are just a way to tell FsCheck that you wantT
in the whole range. They are wrappers aroundT
without any additional behaviour.I see you are an Russian speaker, so you may contact me on The Telegram if you have additional questions (I think issues on GitHub should be readable for everyone and using English here is the right way).
http://t.me/Kharacternyk
Удачи!
It seems right, except that F# version firstly create an arbitrary for
int
and then uses Arb.convert to create an arbitrary forDoNotSize<int>
. I think shrinking wouldn’t work in your version becauseArb.Shrink
tries to find anArbitrary<DoNotSize<int>>
that doesn’t exist yet. The F# version is closer to