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

Updated binding to use modern kernel tests #1507

Merged
merged 3 commits into from
Sep 15, 2023

Conversation

sampersand
Copy link
Contributor

@sampersand sampersand commented Sep 8, 2023

This updates Binding's tests to use the modern version of unit tests.

Also, it updates Binding#clone and Binding#dup to return instance, not self.

@sampersand sampersand marked this pull request as ready for review September 8, 2023 18:24
core/binding.rbs Outdated
@@ -30,9 +30,9 @@
# Binding objects have no class-specific methods.
#
class Binding
def clone: () -> self
def clone: () -> instance
Copy link
Member

Choose a reason for hiding this comment

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

Do you have any specific reason to use instance for those methods?
I think using self is enough and better here. It always returns a Binding object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking self means "the exact same object" (i.e. with def foo: () -> self, self.foo.equal?(self) wouldalways be true), whereas instance means an instance of Binding.

Copy link
Member

Choose a reason for hiding this comment

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

self is the exactly same type of the receiver.
It's different from instance if the type is generic. instance type fills the generic parameters by untyped, so Array[String] will be Array[untyped].

They are identical because Binding is not generic, but I think self is more preferable.


def test_clone
binding.clone
assert_send_type '() -> instance',
Copy link
Member

Choose a reason for hiding this comment

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

It's better to test it with Binding instead of instance (or self).

@soutaro soutaro added this pull request to the merge queue Sep 15, 2023
Merged via the queue into ruby:master with commit c9faa05 Sep 15, 2023
23 checks passed
@soutaro soutaro added this to the RBS 3.3 milestone Oct 31, 2023
@soutaro soutaro added the Released PRs already included in the released version label Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released PRs already included in the released version
Development

Successfully merging this pull request may close these issues.

2 participants