Repository navigation
Add generators for OptionalInt, OptionalLong and OptionalDouble - #33
Merged
Merged
Conversation
Add Generators.optionalInts, optionalLongs and optionalDoubles, which generate the primitive optionals the same way optional generates Optional<T>, and derive them in forType/records. Closes hegeldev#27
blemale
force-pushed
the
primitive-optionals
branch
from
October 12, 2026 13:39
0c4aa96 to
a681b67
Compare
blemale
marked this pull request as ready for review
October 12, 2026 13:48
Contributor
Author
|
The I couldn't reproduce it on Linux x86-64 with Temurin 25.0.4, the JDK the failing job used. One full git archive HEAD | docker run --rm -i --platform linux/amd64 -e CI=true \
maven:3.9-eclipse-temurin-25 bash -c '
mkdir /src && tar -x -C /src && cd /src
apt-get -qq update && apt-get -qq install -y python3 >/dev/null
mvn -B verify'Could someone re-run the failed job? |
Contributor
|
It passed this time and it passed for me locally too several times |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #27.
Summary
Generators.optionalInts(Generator<Integer>),optionalLongs(Generator<Long>)andoptionalDoubles(Generator<Double>). Each generates either an empty primitive optional or one wrapping a value from the given generator, and shrinks toward empty, likeoptional.forType/recordsnow deriveOptionalInt,OptionalLongandOptionalDouble(fromintegers(),longs(),doubles()), sorecord Stats(long count, OptionalLong max, OptionalDouble mean)derives without an override.Review notes
These are new names rather than overloads of
optional, as discussed in the issue. BecauseIntegerGenerator implements Generator<Integer>, anoptional(IntegerGenerator)overload would be picked over the generic one, so existing calls likeoptional(integers().min(0).max(3))would silently change fromOptional<Integer>toOptionalInt, whileoptional(integers().filter(...))would not.Testing
ConformanceTest.optional{Ints,Longs,Doubles}BoundsAndShrinking: for each type, values stay within the inner generator's bounds, an unconstrained draw shrinks to empty, and a present value shrinks to the inner generator's lower bound.GeneratorSmokeTest: draws one value of each type.DerivationTest.derivesPrimitiveOptionals: derives a record with all three.mvn verifypasses locally (both backends, 100% coverage gate);spotless:checkclean.