-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Make Chain Arbitraries recursively build concatenations #2430
Conversation
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.
Looks great, lot better than what I came up with 😁
Codecov Report
@@ Coverage Diff @@
## master #2430 +/- ##
==========================================
+ Coverage 95.21% 95.27% +0.06%
==========================================
Files 351 351
Lines 6369 6350 -19
Branches 286 274 -12
==========================================
- Hits 6064 6050 -14
+ Misses 305 300 -5
Continue to review full report at Codecov.
|
rights.trimEnd(1) | ||
} | ||
// Empty is only top level, it is never internal to an Append | ||
if (rights.nonEmpty) throw new IllegalStateException(s"found internal Empty in $this") |
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.
should we just remove this since 1. we believe this to be true, 2. we have laws to catch this. By removing entirely we improve code coverage and we possibly slightly improve performance.
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.
Yeah sounds good 👍
@@ -461,8 +455,8 @@ object Chain extends ChainInstances { | |||
rights.clear() | |||
currentIterator = seq.iterator | |||
currentIterator.next | |||
case Empty => | |||
go // This shouldn't happen | |||
case null | Empty => |
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.
without the null here we had a match error previously on empty.
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.
Huh, I didn't even know you could pattern match on null 😬
@@ -505,8 +499,8 @@ object Chain extends ChainInstances { | |||
lefts.clear() | |||
currentIterator = seq.reverseIterator | |||
currentIterator.next | |||
case Empty => | |||
go // This shouldn't happen | |||
case null | Empty => |
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.
without the null here we had a match error previously on empty.
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.
LGTM
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.
Thanks!
Ready to merge this @johnynek? |
* Make Chain Arbitraries recursively build concatenations * check some emptyness invariants * improve code coverage by leveraging invariants * test next throws the right exception * remove runtime check * make Chain iterators private
forgive me @LukaJCB I wanted a direct Arbitrary that constructs in all the ways we can (empty, single, concat or fromList).
I think this current generator should create any possible chain with some probability.