Skip to content

Commit

Permalink
Merge pull request #463 from topazproject/tim/fix-Object#inspect
Browse files Browse the repository at this point in the history
fix Object#inspect, this is supposed to call #to_s
  • Loading branch information
alex committed Mar 3, 2013
2 parents 671a27f + 45fad43 commit 96ff4df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/objects/test_objectobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,16 @@ def test_inspect(self, space):
return obj.to_s == obj.inspect
""")
assert w_res == space.w_true
w_res = space.execute("""
class A
def to_s
10
end
end
obj = A.new
return obj.to_s == obj.inspect
""")
assert w_res == space.w_true

def test_send(self, space):
w_res = space.execute("return [1.send(:to_s), 1.send('+', 2)]")
Expand Down
3 changes: 3 additions & 0 deletions topaz/objects/objectobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def method_extend(self, space, w_mod):
self.getsingletonclass(space).extend_object(space, self, w_mod)

@classdef.method("inspect")
def method_inspect(self, space):
return space.send(self, space.newsymbol("to_s"))

@classdef.method("to_s")
def method_to_s(self, space):
return space.newstr_fromstr(space.any_to_s(self))
Expand Down

0 comments on commit 96ff4df

Please sign in to comment.