Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Implements generators for chunks analogous to existing generators for other collection types. Specializes generators for non-empty lists and chunks to return more specific type. Also implements Chunk.fill, Assertion.hasSizeChunk, and Assertion.isEmptyChunk.

@adamgfraser adamgfraser requested a review from jdegoes April 9, 2020 00:39
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I think we’ve accrued some utility generators in StreamUtils like smallChunks, mediumChunks, etc. Would these have a place in Gen?

@iravid
Copy link
Member

iravid commented Apr 9, 2020

Perhaps as generalized small/medium/large combinators

@adamgfraser
Copy link
Contributor Author

We already have generalized small, medium, and large combinators in Gen so you can do small(chunkOf(anyInt)).

I think the other consideration that is relevant is that these generators are not trying to generate different internal representations of chunks. We just take a bunch of values and stick them into a chunk, versus trying to construct chunks from different combinations of subtypes.

I think this is the right behavior for users of Chunk, since they should get the same behavior regardless of whether a chunk is represented as a single array or a concatenation of two arrays, for example. And this is consistent with the treatment of other collection generators like Vector. But for the implementer of chunk it is valuable to have generators of different combinations of subtypes to verify that is actually true.

So what I would suggest is we could do the following:

  1. Move ChunkSpec along with the existing generators in ChunkUtils to core-tests. This file and these generators would be responsible for verifying the correctness of Chunk constructors and combinators.
  2. Move all other generators in stream tests to use new implementation of chunk generators implemented here. This should be a very simple change basically just changing the implementation of smallChunks, etc... to be as described above.

@iravid
Copy link
Member

iravid commented Apr 9, 2020

Sounds good and agreed on the action items! I will also migrate the ZConduit tests once this branch is merged.

@adamgfraser adamgfraser merged commit 3227b67 into zio:master Apr 9, 2020
@adamgfraser adamgfraser deleted the chunk branch April 9, 2020 12:59
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.

2 participants