using list(MockUnitInt) doesn't generate a new random value each time.
See original GitHub issueI am trying to generate lists of data with random size. I started with
MockUnit<T> things;
MockUnit<List<T>> listsOfThings = things.list(ints().range(0, 10));
my expectation from looking at the API was that each time I called listOfThings.val() I’d get a new list with a random size. in practice, the random size is evaluated once, and I get lists of the same size each time.
i’ve worked around this by doing
MockUnit<List<T>> listsOfThings = ints().range(0, 10).map( size -> things.list(size).val());
but that feels awkward.
what’s the intention of MockUnit.list(MockUnitInt) ? would you be open to a PR that evaluates the random size each time a new val is requested?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Random number generator only generating one random number
Every time you do new Random() it is initialized using the clock. This means that in a tight loop you get the same...
Read more >Tutorial - mockneat
Generates a integer value from the given array int[] array = new int[] {1,10 ... a new MockUnit<List<String>> , where each element from...
Read more >Rand and RandBetween functions in Power Apps
Text = Slider1.Value + Rand() then a new random number is generated each time the Slider control's value changes and the label's text...
Read more >Generate Random Numbers That Are Different - MathWorks
One way to get different random numbers is to initialize the generator using a different seed every time. Doing so ensures that you...
Read more >Random Number Generation
The functions RandomChoice and RandomSample sample from a list of values with or ... Generating 10 7 numbers one at a time takes...
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 Free
Top 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

Thank you for your interest. I enjoy when people actually raise those kinds of issues.
Regarding the PRs, there are many ideas hanging, but one of the things I was interested in building were:
Good to hear your ideas! I’ve been primarily using the project to populate tables in a relational DB. I borrowed some from the existing
SQLInsertbut had made my own abstraction a bit more tailored to how I’m using it. I’ll keep your goals in mind as I continue to use the library and help enhance it appropriately.