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] Implemented Integer#digits #4375

Closed
wants to merge 1 commit into from
Closed

[ruby 2.4] Implemented Integer#digits #4375

wants to merge 1 commit into from

Conversation

herwinw
Copy link

@herwinw herwinw commented 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

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

@enebo enebo left a comment

Choose a reason for hiding this comment

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

I think for RubyBignum instances you will need to have two code paths here. I would even break those out and put the implementation in RubyFixnum and RubyBignum.


@JRubyMethod(name = "digits")
public RubyArray digits(ThreadContext context, IRubyObject base) {
long self = ((RubyFixnum)this).getLongValue();
Copy link
Member

Choose a reason for hiding this comment

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

Is this guanteed to be an instance of RubyFixnum? It can also be a RubyBignum.

@herwinw
Copy link
Author

herwinw commented Dec 11, 2016

I don't expect to have a chance to fix this in the next two weeks. If someone wants to finish this: be my guest. Otherwise, it might have to wait a little bit

@whwilder
Copy link
Contributor

I've written a fix for this issue, however I've never contributed to someone else's pull request. I assume I submit a pull request to @herwinw's repository?

@kares
Copy link
Member

kares commented Feb 13, 2017

@whwilder that assumes he will than manage the PR out. and since this is stale for 2 months now ...
you could also just pick his commit(s) and address the concerns raised on top of them (in a separate PR)

@headius
Copy link
Member

headius commented Feb 13, 2017

Yeah, like @kares said, it may be best to just create a new PR based on this one. Github doesn't have a great way for two people in two repos to collaborate on a single PR.

@herwinw
Copy link
Author

herwinw commented Feb 15, 2017

This is continued in #4490, no need to keep this PR opened

@herwinw herwinw closed this Feb 15, 2017
@herwinw herwinw deleted the integer_digits branch February 15, 2017 10:21
@kares kares added this to the Invalid or Duplicate milestone Feb 15, 2017
kares pushed a commit that referenced this pull request Feb 24, 2017
* [ruby 2.4] Implemented Integer#digits

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

* Moved Integer#digits to Fixnum & Bignum

* Fixed some styling issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants