-
-
Notifications
You must be signed in to change notification settings - Fork 394
Fix bigdecimal spec #1290
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
Fix bigdecimal spec #1290
Conversation
80050d8 to
0833f22
Compare
| it "raises ArgumentError when Float is used without precision" do | ||
| -> { BigDecimal(1.0) }.should raise_error(ArgumentError) | ||
| it "allows Float without precision" do | ||
| skip if BigDecimal::VERSION < "3.3.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.
Could you use a version_is guard instead? (see usages of that for examples)
skip should only be used as last resort if there is no other way, i.e. skip should be avoided as much as possible.
Maybe we should doc that better for skip, how did you find skip BTW?
eregon
left a comment
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.
Thank you for the PR, it looks good in general.
library/bigdecimal/remainder_spec.rb
Outdated
| @mixed.remainder(@zero).should.nan? | ||
| @zero.remainder(@zero).should.nan? | ||
| it "raises ZeroDivisionError used with zero" do | ||
| skip if BigDecimal::VERSION < "3.3.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.
Use version_is instead, and same for other usages of skip
Fix for new feature BigDecimal(float). Fix assertion of BigMath.log not to expect incorrect random digits to be appended. Fix assertion of too-strict precision and assertion that expecting precision to be too loose. Fix divmod, modulo and remainder assertion which was expecting a bug inconsistent with Float as a specification. Remove coerce expectation to add/sub/mult which was dropped because of a bug, and never implemented correctly in BigDecmal.
0833f22 to
4ba0080
Compare
BigDecimal v3.3.1
Fix for new feature
BigDecimal(float)Fix assertion of BigMath.log not to expect incorrect random digits to be appended.
Fix assertion of too-strict precision and assertion that expecting precision to be too loose.
Fix divmod, modulo and remainder assertion which was expecting a bug inconsistent with Float as a specification.
Remove coerce expectation to add/sub/mult which was dropped because of a bug, and never implemented correctly in BigDecimal.
Unlike
+ - *,add sub multis required to calculate within BigDecimal and to return BigDecimal.a.coerce(b) #=> [b2, a2]only guarantees thata2.class == b2.class. Numeric's default behavior is to return[Float, Float]. It's not suitable to convert something to BigDecimal.