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

Adds spec for Feature#17260 and Feature#17231 #855

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

baweaver
Copy link
Contributor

@baweaver baweaver commented Oct 6, 2021

Refers to #823

Adds specs for one-line pattern matching syntax in Ruby 3.0+, including
both Righthand Assignment (=>) and one-line match (in).

Notes:

I was confused on how to add specs for only Ruby 2.7 to get NoMatchingPatternError for 0 in 1 as the syntax I'd found will run in Ruby 3.0.

How exhaustive do we want these tests to be? On one hand they could be reasonably inferred from full pattern matches, and we simply want to check that the syntax works. On the other we should likely test edge-cases.

What are thoughts on this?

I can certainly see a case for a more comprehensive test on possible syntax errors and odd uses to ensure consistency, but want to run that by maintainers first.

@baweaver
Copy link
Contributor Author

baweaver commented Oct 6, 2021

Ah, I've noticed that there's range support in the Ruby version blocks. Would that be the recommended way?

EDIT - Went ahead and added that in, going to assume so.

@baweaver baweaver force-pushed the baweaver/ruby-3/one-line-17260 branch from 332ea50 to ae26511 Compare October 6, 2021 04:58

eval(<<~RUBY).should == false
[0, 1] in [a, b, c]
RUBY
Copy link
Contributor Author

Choose a reason for hiding this comment

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

What are thoughts on this convention of negation? Would prefer to make sure there's a definitive behavior being tested both for and against, as I've been bitten by positive-only tests before.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it's definitely useful.

@eregon
Copy link
Member

eregon commented Oct 9, 2022

@baweaver Hello, any chance you could finish this?
If not, please also reply, and then I'll try to address it myself when I get some time.

Adds specs for one-line pattern matching syntax in Ruby 3.0+, including
both Righthand Assignment (`=>`) and one-line match (`in`).
@andrykonchin andrykonchin force-pushed the baweaver/ruby-3/one-line-17260 branch from ae26511 to 90ef78c Compare June 26, 2024 13:47
@andrykonchin andrykonchin merged commit 9fbc6ed into ruby:master Jun 26, 2024
14 checks passed
@andrykonchin
Copy link
Member

Thank you!

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.

3 participants