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

Prevent infinite ranges blowing up matcher descriptions #755

Closed
wants to merge 2 commits into from

Conversation

JonRowe
Copy link
Member

@JonRowe JonRowe commented Mar 17, 2015

Prevent infinite ranges blowing up matcher descriptions, like IO it seems they're not always enumerable. Fixes #754.

JonRowe added a commit that referenced this pull request Mar 17, 2015
[skip ci]
rescue IOError # STDOUT is enumerable but `map` raises an error
# STDOUT is enumerable but `map` raises an error
# Range is enumerable except when infinite
rescue IOError, TypeError
Copy link
Member

Choose a reason for hiding this comment

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

Instead of rescueing TypeError, should we consider changing the definition of enumerable? so that ranges aren't enumerated? After all, even for an enumerable range (e.g. all ints: 1..10), I don't think we want it enumerated in the description. We'd rather just have it inspected and displayed as 1..10, right?

If we go that route, we should perhaps rename enumerable? to should_enumerate? or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

JonRowe added a commit that referenced this pull request Mar 17, 2015
[skip ci]
@JonRowe
Copy link
Member Author

JonRowe commented Mar 17, 2015

Updated

}.to fail_with(infinite_range.inspect)
end

it "doesnt enumerate normal ranges" do
Copy link
Member

Choose a reason for hiding this comment

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

s/doesnt/doesn't/

@myronmarston
Copy link
Member

LGTM. Do you plan to backport this to 3.2?

@JonRowe
Copy link
Member Author

JonRowe commented Mar 17, 2015

Travis doesnt like whatever I did, reopening PR

JonRowe added a commit that referenced this pull request Mar 18, 2015
[skip ci]
JonRowe added a commit that referenced this pull request Mar 18, 2015
JonRowe added a commit that referenced this pull request Mar 18, 2015
JonRowe added a commit that referenced this pull request Mar 18, 2015
[skip ci]
JonRowe added a commit that referenced this pull request Mar 18, 2015
[skip ci]
JonRowe added a commit that referenced this pull request Mar 22, 2015
[skip ci]
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.

TypeError: "can't iterate from Float" when matching Hashes with Ranges
2 participants