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

(#1335) Introduce NumberEnvelope and move number in their package #1587

Merged
merged 3 commits into from
Jun 12, 2021

Conversation

victornoel
Copy link
Collaborator

@victornoel victornoel commented Apr 19, 2021

Last part of #1335: introduce NumberEnvelope and move all the Number implementations to their own packages.

Some tests were passing differently with respect to overflow and stuffs like that: I considered it was ok to change them, but I may have misunderstood their purpose. From my POV, they didn't bring anything particularly useful, but I will ask their original author in comments to review that.

This also covers #1591 and #1496 since they fitted nicely in this PR.

@@ -125,7 +125,7 @@ void withIterableOfInts() {
void overflowIntFromLongValues() {
MatcherAssert.assertThat(
new SumOf(2_147_483_647L + 1L << 1, 10L).intValue(),
new IsEqual<>(2_147_483_647)
new IsEqual<>(10)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@svendiedrichsen I think you originally wrote this test, and I wasn't sure exactly what it was supposed to verify or test, but after changing the way SumOf is implemented, now it gives this result. Do you think this is correct and if not, could you help me understand why? thx!

Copy link
Contributor

@svendiedrichsen svendiedrichsen Apr 19, 2021

Choose a reason for hiding this comment

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

@victornoel I have initially written this test to assure that long overflows during summation don't affect the result. Original commit here: cb97bf0#diff-68e784b552b842bf92ef1a42843f896862c82e87df36dcd69d8cd2561b1ad3b4
SumOf used to do summation using double values and thus being prone to overflow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@svendiedrichsen thank you for your answer. I think the commit you linked to did not change: I was referring to the test this comment here is attached to. I understand the general why, I had seen the commits and messages, but for this particular test, I don't exactly understand why the previous behaviour is correct, and why this new one would not. If you have some insight about it, it would be really helpful :)

Copy link
Contributor

@svendiedrichsen svendiedrichsen Apr 19, 2021

Choose a reason for hiding this comment

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

@victornoel I can't remember anymore. Sorry. But if I had to guess. I think it is a test how the overflow is handled if you request an Int from a number larger than an int.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@svendiedrichsen ok, thanks :) I should find a satisfying solution I think, cheers

@victornoel
Copy link
Collaborator Author

@0crat status

@0crat
Copy link
Collaborator

0crat commented May 2, 2021

@0crat status (here)

@victornoel This is what I know about this job in C63314D6Z, as in §32:

@victornoel
Copy link
Collaborator Author

@andreoss finally, this PR is ready to be reviewed. It's a bit big and I apologized for it, if it's too big, just tell me and I will have to break it into pieces, but if I can avoid it will be easier since there are both changes and moved classes :)

* @since 1.0.0
*/
@SuppressWarnings("serial")
@SuppressFBWarnings("SE_NO_SERIALVERSIONID")
Copy link
Contributor

Choose a reason for hiding this comment

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

@victornoel Why not add seriaId?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andreoss there are some implementation of number for which this do not make sense (the one based on 4 scalars mainly). IMHO EO and serializable classes does not make sense together.

That being said, your comment makes me think that maybe it's best to just leave serial id in case it makes sense :)


/**
* Integer Scalar which sums up the values of other Scalars of the same type
* Int total of numbers.
Copy link
Contributor

Choose a reason for hiding this comment

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

@victornoel Bad renaming?

Matchers.equalTo(3)
1, 2, 3, 4
),
new AllOf<Number>(new IsEqual<>(2.5), new IsEqual<>(2.5))
Copy link
Contributor

Choose a reason for hiding this comment

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

@victornoel
Copy link
Collaborator Author

@andreoss thx, I took your comments into account

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2021

Codecov Report

Merging #1587 (510666e) into master (a9c3bdc) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1587      +/-   ##
============================================
- Coverage     90.16%   90.08%   -0.09%     
+ Complexity     1616     1603      -13     
============================================
  Files           302      298       -4     
  Lines          3784     3750      -34     
  Branches        121      122       +1     
============================================
- Hits           3412     3378      -34     
+ Misses          339      338       -1     
- Partials         33       34       +1     
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/cactoos/Fallback.java 100.00% <ø> (ø) 0.00 <0.00> (ø)
src/main/java/org/cactoos/io/TailOf.java 100.00% <ø> (ø) 10.00 <0.00> (ø)
src/main/java/org/cactoos/iterable/IterableOf.java 95.83% <100.00%> (-0.17%) 15.00 <1.00> (-1.00)
src/main/java/org/cactoos/number/AvgOf.java 100.00% <100.00%> (ø) 6.00 <6.00> (?)
...main/java/org/cactoos/number/ComparableNumber.java 100.00% <100.00%> (ø) 2.00 <2.00> (?)
src/main/java/org/cactoos/number/DivisionOf.java 100.00% <100.00%> (ø) 4.00 <4.00> (?)
src/main/java/org/cactoos/number/MaxOf.java 100.00% <100.00%> (ø) 6.00 <4.00> (?)
src/main/java/org/cactoos/number/MinOf.java 100.00% <100.00%> (ø) 6.00 <4.00> (?)
...main/java/org/cactoos/number/MultiplicationOf.java 100.00% <100.00%> (ø) 3.00 <2.00> (?)
...c/main/java/org/cactoos/number/NumberEnvelope.java 100.00% <100.00%> (ø) 10.00 <10.00> (?)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9c3bdc...510666e. Read the comment docs.

@victornoel victornoel force-pushed the 1335-next branch 2 times, most recently from 51955aa to 3cab66c Compare May 16, 2021 14:17
@victornoel
Copy link
Collaborator Author

@0crat status

1 similar comment
@victornoel
Copy link
Collaborator Author

@0crat status

@0crat
Copy link
Collaborator

0crat commented Jun 10, 2021

@0crat status (here)

@victornoel This is what I know about this job in C63314D6Z, as in §32:

@0crat
Copy link
Collaborator

0crat commented Jun 10, 2021

@0crat status (here)

@victornoel This is what I know about this job in C63314D6Z, as in §32:

@victornoel
Copy link
Collaborator Author

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Jun 12, 2021

@rultor merge

@victornoel OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 510666e into yegor256:master Jun 12, 2021
@rultor
Copy link
Collaborator

rultor commented Jun 12, 2021

@rultor merge

@victornoel Done! FYI, the full log is here (took me 10min)

@victornoel victornoel deleted the 1335-next branch June 12, 2021 14:58
@0crat 0crat added the qa label Jun 12, 2021
@0crat
Copy link
Collaborator

0crat commented Jun 12, 2021

Code review was too long (53 days), architects (@victornoel) were penalized, see §55

@0crat
Copy link
Collaborator

0crat commented Jun 12, 2021

@sereshqua/z please review this job completed by @andreoss/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed

@0crat 0crat removed the 0crat/scope label Jun 12, 2021
@sereshqua
Copy link

@0crat quality good

@0crat 0crat added quality/good and removed qa labels Jun 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants