Skip to content
Permalink
Browse files

Merge pull request #528 from krekoten/object_instance_of

Object##instance_of? raises a TypeError
  • Loading branch information
alex committed Mar 19, 2013
2 parents 1378fb3 + 4ab083b commit 1b31c75630f1d308ab40109eb1917c1f5e5d0c39
Showing with 5 additions and 2 deletions.
  1. +0 −1 spec/tags/core/object/instance_of_tags.txt
  2. +5 −1 topaz/modules/kernel.py
@@ -1,2 +1 @@
fails:Object##instance_of? returns true if given class is object's class
fails:Object##instance_of? raises a TypeError if given an object that is not a Class nor a Module
@@ -13,6 +13,8 @@
from topaz.objects.exceptionobject import W_ExceptionObject
from topaz.objects.procobject import W_ProcObject
from topaz.objects.stringobject import W_StringObject
from topaz.objects.classobject import W_ClassObject
from topaz.objects.moduleobject import W_ModuleObject


class Kernel(Module):
@@ -298,7 +300,9 @@ def method_is_kind_ofp(self, space, w_mod):

@moduledef.method("instance_of?")
def method_instance_of(self, space, w_mod):
return space.newbool(space.getnonsingletonclass(self) is w_mod)
if isinstance(w_mod, W_ClassObject) or isinstance(w_mod, W_ModuleObject):
return space.newbool(space.getnonsingletonclass(self) is w_mod)
raise space.error(space.w_TypeError, "class or module required")

@moduledef.method("eval")
def method_eval(self, space, w_source):

0 comments on commit 1b31c75

Please sign in to comment.
You can’t perform that action at this time.