-
-
Notifications
You must be signed in to change notification settings - Fork 389
Add specs for reserved keywords #1187
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
base: master
Are you sure you want to change the base?
Conversation
8908ead
to
2cc6546
Compare
language/reserved_keywords.rb
Outdated
# Copied from Prism::Translation::Ripper | ||
keywords = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: It would be nice to have one canonical list that can be used in all these places:
spec/ruby/language/hash_spec.rb
spec/ruby/language/reserved_keywords.rb
lib/prism/translation/ripper.rb
- Ideally, it would also be nice to generate
doc/keywords.rdoc
from that list, to ensure that all keywords are documented.
Where should such a canonical list live?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way to avoid duplication there, since it's files in different repositories.
So for ruby/spec let's have it as a new file under language/fixtures
.
I think a %w[]
array would be nice for this BTW.
FWIW in ruby/ruby there is also defs/keywords
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, done: 0f54929
(#1187)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding these specs seems good but they should match the existing style and structure of ruby/spec, I'll review in more details once it does.
language/reserved_keywords.rb
Outdated
__LINE__ | ||
] | ||
|
||
keywords.each do |kw| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keywords.each do |kw| | |
keywords.each do |name| |
kw
feels too confusing here, especially since there is a spec about keyword arguments below.
Since we are mostly testing names for variables/methods, name
seems clearer in usages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmmm I disagree, in a spec focused on describing the behaviour of keywords, I would expect "keyword" to a be prominent term. It's an overloaded term, but that's just how Ruby is already. Perhaps keyword
is better than kw
?
Anyway, I renamed to name
Thanks for taking another stab at this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I think that's everything addressed.
I kept the history in tract to make it easier to review, but I'll squash and rebase before merging
language/reserved_keywords.rb
Outdated
__LINE__ | ||
] | ||
|
||
keywords.each do |kw| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmmmm I disagree, in a spec focused on describing the behaviour of keywords, I would expect "keyword" to a be prominent term. It's an overloaded term, but that's just how Ruby is already. Perhaps keyword
is better than kw
?
Anyway, I renamed to name
Add specifications for all the reserved keywords, documenting which of them can be used as: