Comments (6)
New features available in 1.8.0-SNAPSHOT
from jqwik.
@esfomeado Thanks for raising that issue.
I see why you‘d expect that repeatChars(0)
to not create any duplicate chars at all. Currently it just sets the probability of explicitly adding duplicate chars to 0. The effect you see is due to edge case resolution.
I’ll have to think about if changing the behaviour or documentation of repeatChars
is the right thing to do. Maybe an additional uniqueChars()
would be even clearer.
To solve your problem short-term, you can use withoutEdgeCases() on the strings arbitrary:
Arbitraries.strings().alpha()
.ofMinLength(5).ofMaxLength(25)
.repeatChars(0.0)
.withoutEdgeCases();
This will prevent „AAAAA“ to be generated on purpose. Duplicate chars will still occur by chance though.
If you definitely want no duplicates, you’d currently have to take a detour through something like:
Arbitraries.chars().alpha().list()
.ofMinSize(5).ofMaxSize(25)
.uniqueElements()
.map(chars -> chars.stream().map(String::valueOf).collect(Collectors.joining()));
from jqwik.
I decided to introduce an experimental new API method: StringArbitrary.uniqueChars()
The open question is if StringArbitrary.repeatChars(0.0)
should log a warning or just call uniqueChars
implicitly, or both?
@esfomeado What do you think?
from jqwik.
Thanks for the quick response.
@jlink Personally I would expect to have the same behaviour was uniqueChars
when set to 0 so I would say to just call uniqueChars
implicitly.
from jqwik.
The StringArbitrary.uniqueChars()
functionality and the fix for repeatChars(0.0)
is available in 1.8.0-SNAPSHOT
.
from jqwik.
In addition, there's now an annotation @UniqueChars
that can be applied to any String
parameter in a property.
from jqwik.
Related Issues (20)
- Allow parallel test runs with SBT HOT 15
- Infinite action chains biased towards small sizes HOT 5
- 1.8.0 contracts regression HOT 16
- IllegalArgumentException: "At least one shrinkable is required" during shrinking hides cause of test failure HOT 4
- Consider supporting @UseType for sealed interfaces HOT 8
- Shrinking of large arrays uses a very large amount of memory HOT 11
- StackOverflowError when shrinking large arrays HOT 14
- question: any way to imperatively summon a pre-configured arbitrary? HOT 15
- Make nested groups work for JDK >= 18 HOT 31
- Combinators.combine.as nullability of arguments HOT 4
- Can't figure out how to create an Arbitrary I want HOT 10
- Bug: Arbitraries.strings().uniqueChars() will sometimes shrink to values with duplicate chars HOT 5
- Bug: Uniform Distribution of Integers does not work if range is >= Integer.MAX_VALUE HOT 2
- Kotlin K2 Support HOT 23
- Time Module: Support generating java.sql.Timestamp
- adding `jqwik-kotlin` causes existing tests written in java to fail with NPE HOT 18
- Potential idea for running `SAMPLE_FIRST`/`SAMPLE_ONLY` for stateful tests HOT 2
- Lifecycle method called twice when subclassing HOT 4
- Cannot use Arbitrary.generator() outside jqwik HOT 6
- Is Arbitrary<@Nullable T> correct/intended under JSpecify semantics? HOT 32
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jqwik.