Skip to content
Browse files

Merge pull request #696 from krekoten/module_remove_const

  • Loading branch information
alex committed May 10, 2013
2 parents e833f92 + 15c7e85 commit 3757697d3bed9071fb9b7fbad209805ca351ef84
Showing with 13 additions and 5 deletions.
  1. +0 −5 spec/tags/core/module/remove_const_tags.txt
  2. +13 −0 topaz/objects/
@@ -1,6 +1 @@
fails:Module#remove_const removes the constant specified by a String or Symbol from the receiver's constant table
fails:Module#remove_const returns the value of the removed constant
fails:Module#remove_const raises a NameError if the name contains non-alphabetic characters except '_'
fails:Module#remove_const calls #to_str to convert the given name to a String
fails:Module#remove_const raises a TypeError if conversion to a String by calling #to_str fails
fails:Module#remove_const is a private method
@@ -533,6 +533,19 @@ def method_const_set(self, space, const, w_value):
space.set_const(self, const, w_value)
return w_value

@classdef.method("remove_const", name="str")
def method_remove_const(self, space, name):
w_res = self.find_local_const(space, name)
if w_res is None:
self_name = space.obj_to_s(self)
raise space.error(space.w_NameError,
"uninitialized constant %s::%s" % (self_name, name)
del self.constants_w[name]
return w_res

@classdef.method("class_variable_defined?", name="symbol")
def method_class_variable_definedp(self, space, name):
return space.newbool(self.find_class_var(space, name) is not None)

0 comments on commit 3757697

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