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

Add specs for Coverage.supported? #1039

Merged
merged 1 commit into from
May 25, 2023

Conversation

AI-Mozi
Copy link
Contributor

@AI-Mozi AI-Mozi commented May 23, 2023

#1016
[Feature #19026]

Coverage.supported?(mode) enables detection of what coverage modes are
supported.

@AI-Mozi AI-Mozi force-pushed the add_specs_for_coverage_supported branch 2 times, most recently from 58b7876 to ec86da2 Compare May 23, 2023 14:12
@AI-Mozi AI-Mozi marked this pull request as ready for review May 23, 2023 14:12
Coverage.supported?(:foo).should == false
Coverage.supported?(:bar).should == false
end
end
Copy link
Member

@andrykonchin andrykonchin May 23, 2023

Choose a reason for hiding this comment

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

minor: It's kind of feature discovering mechanism so it doesn't make sense to require in specs some specific result (true or false).

IMHO the only thing that could be checked is that this method:

  • returns true or false (for existing modes and arbitrary Symbols)
  • converts its argument to Symbol

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it converts argument to Symbol? Isn't it raising an error?

Copy link
Member

Choose a reason for hiding this comment

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

TBH I haven't checked. I meant handling of not Symbol arguments in general.

@AI-Mozi AI-Mozi force-pushed the add_specs_for_coverage_supported branch from ec86da2 to a8b0cef Compare May 23, 2023 15:37
Coverage.supported?(:methods).should == true
Coverage.supported?(:eval).should == true
Coverage.supported?(:all).should == false
end
Copy link
Member

@andrykonchin andrykonchin May 24, 2023

Choose a reason for hiding this comment

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

I meant something like this:

[true, false].should.include?(Coverage.supported?(:lines))

or

(Coverage.supported?(:lines) == true || Coverage.supported?(:lines) == false).should == true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For arbitrary Symbols that are not lines, branches, methods nor eval it should always return false?

Copy link
Member

Choose a reason for hiding this comment

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

I think so.

@AI-Mozi AI-Mozi force-pushed the add_specs_for_coverage_supported branch 2 times, most recently from 335b794 to fade356 Compare May 24, 2023 16:02
[true, false].should.include?(Coverage.supported?(:branches))
[true, false].should.include?(Coverage.supported?(:methods))
[true, false].should.include?(Coverage.supported?(:eval))
Coverage.supported?(:all).should == false
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: I would move the last case into a separate it, e.g. it returns false for not existing modes, and use obviously not existing modes like :foo, :bar etc. :all is too meaningful and looks like correct mode name.

@AI-Mozi AI-Mozi force-pushed the add_specs_for_coverage_supported branch from fade356 to e6a4441 Compare May 25, 2023 06:45
@andrykonchin
Copy link
Member

Thank you!

@andrykonchin andrykonchin merged commit 00057fc into ruby:master May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants