-
Notifications
You must be signed in to change notification settings - Fork 170
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
#532 Declarative fix of AvgOf() bug on Double edge values #581
Conversation
…or all Java Number types (Float.MAX_VALUE, Integer.MAX_VALUE, Long.MAX_VALUE)
…chsen code polish (nice and clean) and added more test cases according @fabriciofx comments. Decimal precision problem solved as well.
Job #581 is now in scope, role is |
Codecov Report
@@ Coverage Diff @@
## master #581 +/- ##
============================================
+ Coverage 67.4% 67.86% +0.46%
+ Complexity 994 971 -23
============================================
Files 207 207
Lines 3436 3277 -159
Branches 254 214 -40
============================================
- Hits 2316 2224 -92
+ Misses 1049 998 -51
+ Partials 71 55 -16
Continue to review full report at Codecov.
|
(len) -> len > 0, | ||
(len) -> new Reduced<>( | ||
BigDecimal.ZERO, | ||
BigDecimal::add, |
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.
Probably should use BigDecimal#add(java.math.BigDecimal, java.math.MathContext)
to be consisted with divide below
}); | ||
this( | ||
new Mapped<>( | ||
(number) -> () -> number, |
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.
unnecessary parenthises, does not correspond with style used in library
}); | ||
this( | ||
new Mapped<>( | ||
(number) -> () -> number, |
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.
unnecessary parenthises, does not correspond with style used in library
}); | ||
this( | ||
new Mapped<>( | ||
(number) -> () -> number, |
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.
unnecessary parenthises, does not correspond with style used in library
}); | ||
this( | ||
new Mapped<>( | ||
(number) -> () -> number, |
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.
unnecessary parenthises, does not correspond with style used in library
BigDecimal.ZERO, | ||
BigDecimal::add, | ||
new Mapped<>( | ||
(number) -> BigDecimal.valueOf( |
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.
unnecessary parenthises, does not correspond with style used in library
BigDecimal.valueOf(len), | ||
MathContext.DECIMAL128 | ||
).doubleValue(), | ||
(len) -> 0.0 |
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.
unnecessary parenthises, does not correspond with style used in library
} | ||
|
||
@Test | ||
public void withIterableOfScalars() { |
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.
in this test type of new IterableOf<Scalar<Number>>(() -> 1L, () -> 2L, () -> 10L)
can be inferred, so params are not neccecary
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 it the compiler complains:
[WARNING] yegor256/cactoos/src/test/java/org/cactoos/scalar/AvgOfTest.java:[358,17] unchecked generic array creation for varargs parameter of type org.cactoos.Scalar<java.lang.Number>[]
And we have -Werror
enabled.
() -> new MinOf(1.0d, 2.0d), | ||
() -> new MaxOf(2.0d, 4.0d), | ||
() -> new SumOf(1.0d, 2.0d, 2.0d), | ||
new Ternary<>(true, 5.0, 1.0d) |
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.
why just 5.0
without d
or why d
is need here at all?
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.
@neonailol typo. They (d
-s) were in the original code I inherited. I kept using the for the consistency. I can remove them if it does not correspond with the style of the library. :)
public void withFloatScalarsIntValue() { | ||
MatcherAssert.assertThat( | ||
new AvgOf( | ||
() -> 1f, () -> 2f, () -> 10f |
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.
please format floats as 1.0f
@neonailol fixed your remarks. Please take a look again. |
Thank you, looks good to me |
@yegor256 this pull request can be merged into master |
@rultor merge |
Order was successfully finished: +15 points just awarded to @neonailol/z, total is +180 |
The job #581 is now out of scope |
#532 is mine now: #532 (comment) Based on #543
Close #532 close #543