Skip to content

Fewer shared examples for ARGF/Array/Complex/Data/Dir/Encoding#1368

Merged
eregon merged 6 commits into
ruby:masterfrom
Earlopain:fewer-shared-examples
May 31, 2026
Merged

Fewer shared examples for ARGF/Array/Complex/Data/Dir/Encoding#1368
eregon merged 6 commits into
ruby:masterfrom
Earlopain:fewer-shared-examples

Conversation

@Earlopain
Copy link
Copy Markdown
Contributor

Working my way through these. #1364

Before:
3804 files, 35682 examples, 278464 expectations, 0 failure, 0 errors, 0 tagged

After:
3805 files, 35512 examples, 292300 expectations, 0 failure, 0 errors, 0 tagged

170 fewer specs.

Also add a test for `ARGF.inspect`, which is an alias for `ARGF.to_s`.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Continues the project of replacing one-method shared examples with direct alias equality checks (per issue #1364). Behavior specs are moved into the canonical method's spec file, and alias spec files now assert Method#==/UnboundMethod#== against the canonical method. Net effect: 170 fewer examples, but more expectations and equivalent coverage.

Changes:

  • Inlined shared example bodies into canonical spec files for ARGF, Array, Complex, Data, Dir, and Encoding.
  • Replaced shared-example invocations in alias spec files with Method#==/UnboundMethod#== assertions; added a new ARGF#inspect alias spec.
  • Deleted the corresponding now-unused shared/ files.

Reviewed changes

Copilot reviewed 90 out of 90 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
core/argf/{readlines,pos,fileno,filename,eof,each_line,each_byte,each_char,each_codepoint}_spec.rb Inlined canonical behavior from shared specs.
core/argf/{to_a,to_i,tell,path,each,inspect}_spec.rb Replaced shared spec with alias equality check (inspect_spec.rb is new).
core/argf/shared/{readlines,pos,fileno,filename,eof,each_line,each_byte,each_char,each_codepoint}.rb Removed.
core/array/{collect,find_index,inspect,join,length,push,replace,select,unshift,element_reference}_spec.rb Inlined canonical behavior.
core/array/{append,filter,index,map,prepend,size,slice,to_s}_spec.rb Replaced shared specs with alias checks.
core/array/shared/{collect,index,inspect,join (partial),length,push,replace,select,slice,unshift}.rb Removed (join still keeps array_join_with_string_separator).
core/complex/{abs,arg,conjugate,divide,imaginary,rectangular}_spec.rb Inlined canonical behavior.
core/complex/{angle,conj,imag,magnitude,phase,quo,rect}_spec.rb Replaced shared specs with alias checks.
core/complex/shared/{abs,arg,conjugate,divide,image,rect}.rb Removed.
core/data/inspect_spec.rb, core/data/to_s_spec.rb, core/data/shared/inspect.rb Behavior moved to inspect_spec.rb; to_s_spec.rb now alias-checks; shared file removed.
core/dir/{tell,path,pwd,open,exist}_spec.rb Inlined canonical behavior.
core/dir/{to_path,pos,getwd}_spec.rb Replaced shared specs with alias checks.
core/dir/shared/{exist,open,path,pwd}.rb, core/dir/shared/pos.rb Removed (pos keeps dir_pos_set).
core/encoding/name_spec.rb, core/encoding/to_s_spec.rb, core/encoding/shared/name.rb Behavior inlined into name_spec.rb; to_s_spec.rb alias-checks; shared file removed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/array/select_spec.rb Outdated
Comment thread core/complex/rectangular_spec.rb Outdated
@Earlopain Earlopain force-pushed the fewer-shared-examples branch from af1dbef to 9bd9081 Compare May 31, 2026 20:05
Copy link
Copy Markdown
Member

@eregon eregon left a comment

Choose a reason for hiding this comment

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

Great!

Do you do these manually with some search/replace or you have some script or something?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 90 out of 90 changed files in this pull request and generated no new comments.

@eregon eregon merged commit e939c6e into ruby:master May 31, 2026
14 checks passed
@Earlopain
Copy link
Copy Markdown
Contributor Author

Do you do these manually with some search/replace or you have some script or something?

Nah, it's pretty manual. Seach and replace works ok, just do it twice (once for no arguments, and once with to take
care of the different ) position).

I wanted to use RDoc to tell me what are aliases but it actually doesn't show for class methods, that's a bit annoying. But I check all the shared examples anyways because there are some that are only used once for historic reasons (like being aliased in the past but it got removed).

Surely it can be done in a better way but I'll be done with this soon anways.

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.

3 participants