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

Fix Method equalitiy #3407

Merged
merged 3 commits into from May 24, 2015
Merged

Fix Method equalitiy #3407

merged 3 commits into from May 24, 2015

Conversation

tak1n
Copy link
Member

@tak1n tak1n commented May 24, 2015

A Method defined via def has an executable attribute of class Rubinius::CompiledCode. On the other site a method defined via define_method has an executable attribute of class Rubinius::BlockEnvironment::AsMethod.

Comparing method equality includes the comparison of executable equality.

For comparing an executable of type Rubinius::BlockEnvironment::AsMethod against an executable of Rubinius::CompiledCode results in an error because it tries to access the block_env attribute on an Rubinius::CompiledCode object, which doesn't exist.

This PR adds an early return like in Rubinius::CompiledCode#==

This closes #3118

tak1n added 2 commits May 24, 2015 01:34
A Method defined via def has an executable attribute of class
Rubinius::CompiledCode. On the other site a method defined via
define_method has an executable attribute of class
Rubinius::BlockEnvironment::AsMethod.

Comparing method equality includes the comparison of executable
equality.

For comparing an executable of type Rubinius::BlockEnvironment::AsMethod
against an executable of Rubinius::CompiledCode results in an error because it tries
to access the block_env attribute on an Rubinius::CompiledCode object,
which doesn't exist.

This commit adds an early return like in Rubinius::CompiledCode#==
@@ -54,6 +54,16 @@
@m_foo.send(@method, m2).should be_true
end

it "returns false if comparing a method defined via define_method and def" do
MethodSpecs::Methods.send :define_method, :defined_foo, lambda {}
Copy link
Member

Choose a reason for hiding this comment

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

I think we should avoid modifying the fixtures from within the spec bodies.
It looks like MethodSpecs::Methods already has some methods defined with define_method. You could probably use one of those, or move your defined method to that file.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, just used it because it was used in the above spec example :)
I'll change it

jemc added a commit that referenced this pull request May 24, 2015
@jemc jemc merged commit 73e862e into master May 24, 2015
@jemc jemc deleted the method-equality-3118 branch May 24, 2015 18:03
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.

undefined method `block_env' on an instance of Rubinius::CompiledCode
2 participants