-
Notifications
You must be signed in to change notification settings - Fork 215
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
Updated binding to use modern kernel tests #1507
Conversation
core/binding.rbs
Outdated
@@ -30,9 +30,9 @@ | |||
# Binding objects have no class-specific methods. | |||
# | |||
class Binding | |||
def clone: () -> self | |||
def clone: () -> instance |
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.
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.
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.
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
.
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.
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.
test/stdlib/Binding_test.rb
Outdated
|
||
def test_clone | ||
binding.clone | ||
assert_send_type '() -> instance', |
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.
It's better to test it with Binding
instead of instance
(or self
).
This updates
Binding
's tests to use the modern version of unit tests.Also, it updates
Binding#clone
andBinding#dup
to returninstance
, notself
.