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

[ruby 2.4] Fixes for Integer#digits in PR #4375 #4490

Merged
merged 4 commits into from Feb 24, 2017
Merged

Conversation

@whwilder
Copy link
Contributor

@whwilder whwilder commented Feb 13, 2017

I've split the implementation for Integer#digits amongst Fixnum and Bignum, which should fix the issues in #4375

ref #4293

herwinw and others added 3 commits Dec 9, 2016
It passes all the following tests of TestInteger of MRI:

* test_digits
* test_digits_for_negative_numbers
* test_digits_for_invalid_base_numbers
* test_digits_for_non_integral_base_numbers
* test_digits_for_non_numeric_base_argument
Copy link
Member

@headius headius left a comment

I know some of these style issues were in the original, but you're active so you're the lucky one :-)

@Override
public RubyArray digits(ThreadContext context, IRubyObject base) {

long self = ((RubyFixnum)this).getLongValue();

This comment has been minimized.

@headius

headius Feb 13, 2017
Member

This is not necessary...this is already known to be RubyFixnum.

*/
@Override
public RubyArray digits(ThreadContext context, IRubyObject base) {
BigInteger self = (this).getValue();

This comment has been minimized.

@headius

headius Feb 13, 2017
Member

You could just access the field here, or at least call it without the parens. I assume this is just a mistake converting the RubyFixnum-only logic.

public RubyArray digits(ThreadContext context, IRubyObject base) {
BigInteger self = (this).getValue();
if (self.compareTo(new BigInteger("0")) == -1) {
throw context.getRuntime().newMathDomainError("out of domain");

This comment has been minimized.

@headius

headius Feb 13, 2017
Member

Throw context.runtime into a local variable at the top and reuse it, in the style of other methods.

@whwilder
Copy link
Contributor Author

@whwilder whwilder commented Feb 14, 2017

Thanks for the help! Squashed a few other style issues too.

@whwilder
Copy link
Contributor Author

@whwilder whwilder commented Feb 23, 2017

@headius Is there anything preventing this PR from being merged, or is it just a low priority for the moment?

@kares kares merged commit d84615c into jruby:ruby-2.4 Feb 24, 2017
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@kares
Copy link
Member

@kares kares commented Feb 24, 2017

@whwilder great work - wanted to get #digits in as well, thanks :)

@kares kares added this to the JRuby 9.2.0.0 milestone Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.