Skip to content

Fix up last few alias tests in core#1373

Merged
eregon merged 2 commits into
ruby:masterfrom
Earlopain:core-cleanup
Jun 5, 2026
Merged

Fix up last few alias tests in core#1373
eregon merged 2 commits into
ruby:masterfrom
Earlopain:core-cleanup

Conversation

@Earlopain
Copy link
Copy Markdown
Contributor

And also one for zlib.

Previously I just checked core/*/shared.
But some didn't use that, and others I skipped by accident.

I used the following script (with --disable-gems) to find aliased methods:

require "objspace"

r = {}
ObjectSpace.each_object(Module) do |mod|
  next if mod.inspect.include?("<Object:")
  methods = mod.public_instance_methods.map { mod.instance_method(it) }
  methods += mod.public_methods.map { mod.method(it) }
  methods.each do |meth|
    to_find = methods.select { it.name != meth.name }
    next if to_find.none? { it == meth }
    next if meth.owner != (meth.is_a?(Method) ? mod.singleton_class : mod )
    r[mod] ||= []
    r[mod] << meth
  end
end

r = r.transform_values do |methods|
  methods.group_by(&:itself).values
end

pp r

Closes #1364

Earlopain added 2 commits June 4, 2026 21:52
Also use the `complain` matcher instead of `ruby_exe`
And also one for zlib.

Previously I just checked core/*/shared.
But some didn't use that, and others I skipped by accident.

I used the following script (with `--disable-gems`) to find aliased methods:

```rb
require "objspace"

r = {}
ObjectSpace.each_object(Module) do |mod|
  next if mod.inspect.include?("<Object:")
  methods = mod.public_instance_methods.map { mod.instance_method(it) }
  methods += mod.public_methods.map { mod.method(it) }
  methods.each do |meth|
    to_find = methods.select { it.name != meth.name }
    next if to_find.none? { it == meth }
    next if meth.owner != (meth.is_a?(Method) ? mod.singleton_class : mod )
    r[mod] ||= []
    r[mod] << meth
  end
end

r = r.transform_values do |methods|
  methods.group_by(&:itself).values
end

pp r
```
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.

Thank you!

@eregon eregon merged commit baf5738 into ruby:master Jun 5, 2026
14 checks passed
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.

Specs for aliased methods

2 participants