Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Array, Set and Dictionary #12

Merged
merged 1 commit into from
Jul 2, 2023
Merged

Conversation

liamnichols
Copy link
Owner

Closes #9

Fixture wasn't able to produce a value for collections unless it was registered already. I thought of two ways to handle this more generically:

  1. If the Element (or Key & Value) were already registered, we could return a collection with a single element of those types (this keeps things non-deterministic)
  2. Otherwise just produce an empty collection

I was going to bake custom behaviour into Fixture.value(for:overrides:) but I instead opted to just make Array, Set and Dictionary conform to FixtureProviding. I was a bit on the fence about this since I didn't really want to conform system types to the public protocol (which is why we have the registration system in the first place) but the only other option was to have a separate similar internal protocol and that didn't make sense either.

Since this is a system type, and it's a protocol that we own, I don't see that adding FixtureProviding conformance ourselves is such a big problem. If it becomes one in the future though, we can revisit for sure.

@liamnichols liamnichols self-assigned this Jul 2, 2023
@liamnichols liamnichols merged commit 62666af into main Jul 2, 2023
8 checks passed
@liamnichols liamnichols deleted the ln/collection-types branch July 2, 2023 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for collection types
1 participant