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

Implement Random for BigInt #6687

Merged
merged 5 commits into from
Sep 10, 2018
Merged

Implement Random for BigInt #6687

merged 5 commits into from
Sep 10, 2018

Conversation

oprypin
Copy link
Member

@oprypin oprypin commented Sep 8, 2018

Copy link
Contributor

@Sija Sija left a comment

Choose a reason for hiding this comment

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

Perhaps the extension should live in src/big/big_int.cr instead of being directly implemented in src/random.cr?

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

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

The additions to Random should go in big_int.cr

x.should be >= 0
x.should be < 2

rand(0.to_big_i).should eq(0.to_big_i)
Copy link
Member

Choose a reason for hiding this comment

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

This contradicts with #6686

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, whichever of those gets merged 2nd, will need to be changed

@@ -115,6 +143,12 @@ describe "Random" do
expect_raises ArgumentError, "Invalid range for rand: 1..0" do
rand(1..0)
end
expect_raises ArgumentError, "Invalid range for rand: 1_big_i...1_big_i" do
Copy link
Member

Choose a reason for hiding this comment

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

1_big_i isn't a thing. Maybe better use 1.to_big_i as in code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well I didn't make this up, it's just to_s. But a good idea to change that to also rely on to_s.

Copy link
Contributor

@ysbaddaden ysbaddaden left a comment

Choose a reason for hiding this comment

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

Let's merge if on phase with #6686

@oprypin
Copy link
Member Author

oprypin commented Sep 10, 2018

Yeah this is ready, as long as there are no merge conflicts

@RX14 RX14 merged commit ccbfd8b into crystal-lang:master Sep 10, 2018
@RX14 RX14 added this to the 0.27.0 milestone Sep 10, 2018
ezrast pushed a commit to ezrast/crystal that referenced this pull request Oct 2, 2018
* Implement Random for BigInt

Fixes crystal-lang#5647

* spec typo fix

* Move to big_int.cr

* Use to_s in spec

* Remove special case of zero because it will be removed in crystal-lang#6686
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.

6 participants