-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: create collections with unique elements #102 (WIP)
This is a dirty hack, just do show that it is possible. This still needs work.
- Loading branch information
1 parent
418d01c
commit c482aeb
Showing
3 changed files
with
54 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
c482aeb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, because it circumvents the cache by creating a new Context for every element. However, if you want to create a collection of collections, e.g.
List<List<Object>>
, the inner lists will still only ever have duplicate elements of the same instance, orSet<Set<Object>>
will have wrong inner set-sizes, I expect.I like the idea though; maybe we can leverage it by going a few steps deeper: In the
CollectionSpecimen
we build a new specimen for the inner type:Maybe we can create a new
SpecimenFactory
at this level, instead of using the existing instance. We could pass a copy of the existingContext
down with the cache cleaned.Current:
Idea:
Problem is, that we lose the "predefined" instances - those are customised, e.g. if the user wants all String instances to be "foo". Maybe we can separate the general cache from the predefined instances?
c482aeb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will solve the problem of sets with only one member.
Unfortunately it creates the problem with the circular dependency (see
JavaFixture/src/test/java/com/github/nylle/javafixture/FixtureTest.java
Line 286 in 418d01c