Skip to content

Commit

Permalink
Merge pull request topazproject#541 from krekoten/kernel_respond_to_m…
Browse files Browse the repository at this point in the history
…issing

Implemented Kernel#respond_to_missing? (almost)
  • Loading branch information
alex committed Mar 22, 2013
2 parents f118a84 + e887d70 commit 8d8e46c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 0 additions & 9 deletions spec/tags/core/kernel/respond_to_missing_tags.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
fails:Kernel#respond_to_missing? is called with a 2nd argument of false when #respond_to? is
fails:Kernel#respond_to_missing? is called a 2nd argument of false when #respond_to? is called with only 1 argument
fails:Kernel#respond_to_missing? is called with true as the second argument when #respond_to? is
fails:Kernel#respond_to_missing? is called when #respond_to? would return false
fails:Kernel#respond_to_missing? causes #respond_to? to return true if called and not returning false
fails:Kernel#respond_to_missing? causes #respond_to? to return false if called and returning false
fails:Kernel#respond_to_missing? causes #respond_to? to return false if called and returning nil
fails:Kernel#respond_to_missing? is called when obj responds to the given private method, include_private = false
fails:Kernel#respond_to_missing? is called for missing class methods
fails:Kernel#respond_to_missing? returns true if obj responds to the given public method
14 changes: 13 additions & 1 deletion topaz/modules/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,19 @@ def method_instance_variable_definedp(self, space, name):

@moduledef.method("respond_to?", include_private="bool")
def method_respond_top(self, space, w_name, include_private=False):
return space.newbool(space.respond_to(self, w_name))
if space.respond_to(self, w_name):
return space.newbool(True)

w_found = space.send(
self,
space.newsymbol("respond_to_missing?"),
[w_name, space.newbool(include_private)]
)
return space.newbool(space.is_true(w_found))

@moduledef.method("respond_to_missing?")
def method_respond_to_missingp(self, space, w_name, w_include_private):
return space.newbool(False)

@moduledef.method("dup")
def method_dup(self, space):
Expand Down

0 comments on commit 8d8e46c

Please sign in to comment.