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

Spec size method calls on Enumerator instances returned by Enumerable methods. #3318

Merged
merged 5 commits into from
Feb 17, 2015

Conversation

fmfdias
Copy link
Contributor

@fmfdias fmfdias commented Feb 15, 2015

Hi,

A few days ago I've opened this issue regarding calling size on the Enumerator instance that results on calling the Enumerable#each_slice without a block.

At the time I only checked that method. A few days after I thought on checking other similar Enumerable methods that return an Enumerator, on MRI 2.1.5, Rubinius 2.5.2 and JRuby 9.0.0.0 pre1.
Rubinius returns nil on all the calls which is not the behavior of MRI. JRuby was only failing on each_slide.
Unfortunately I wasn't able to finish it and inform you guys of it before the issue was handled and closed.

I took a look at the tests that were added for the each_slice fix pull request and, based on it, decided to transform the checks I made in specs that could be useful.

I tried to cover all the Enumerable methods that I could find. I also checked the Array class and added similar tests to the methods implemented/overridden by the Array class that are on the same situation.

I hope it helps.

Thank you!

… Enumerable methods that return an Enumerator.
The tests check if the size method on the resulting Enumerator instance returns the correct value.
The tests check if the size method on the resulting Enumerator instance returns the correct value.
@fmfdias fmfdias changed the title Spec enumerable size Spec size method calls on Enumerator instances returned by Enumerable methods. Feb 15, 2015
@jemc
Copy link
Member

jemc commented Feb 16, 2015

@fmfdias
Thanks for taking the time to write some specs! However, we need to tag these as failing so that they don't cause CI orrake spec failures.

Take a look at mspec tag --help for more information, but the most basic tagging of failures looks something like mspec tag fails ./spec. This will add files or lines to the directory structure in ./spec/tags that mirrors the structure of the specs in ./spec. Those tag changes can then be committed to the repository. You should then be able to run rake spec locally, without any failures.

@fmfdias
Copy link
Contributor Author

fmfdias commented Feb 16, 2015

Hi @jemc

I've tagged them as failing.
Thank you for the feedback.

Cheers

@yorickpeterse
Copy link
Contributor

Travis seems to fail due to a race condition unrelated to these changes (https://travis-ci.org/rubinius/rubinius/jobs/50984264), otherwise looks good to me 👍

@@ -44,4 +44,9 @@
multi = EnumerableSpecs::YieldsMulti.new
multi.drop_while {|e| e != [6, 7, 8, 9] }.should == [[6, 7, 8, 9]]
end

it "returns the nil as size when no block is given" do
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should just be "returns nil as size...", unless nil is suddenly a person/object 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got caught, hehehe. I think it could also give a nice a movie title... 'The Nil' 😄

jemc added a commit that referenced this pull request Feb 17, 2015
Spec size method calls on Enumerator instances returned by Enumerable methods.
@jemc jemc merged commit 6fc3e47 into rubinius:master Feb 17, 2015
@fmfdias fmfdias mentioned this pull request Feb 18, 2015
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

3 participants