Skip to content
Browse files

Merge pull request #529 from modcloth/mbh/main-to_s-with-toplevel-bin…


Kernel#eval, TOPLEVEL_BINDING, and top #to_s returns "main"
  • Loading branch information
alex committed Mar 19, 2013
2 parents ee7431b + fe095ab commit 4dff19995756db32052205f244c8b1f8364abf6d
Showing with 12 additions and 7 deletions.
  1. +2 −0 lib-topaz/top_self.rb
  2. +0 −3 spec/tags/core/kernel/eval_tags.txt
  3. +0 −1 spec/tags/core/main/to_s_tags.txt
  4. +10 −3 topaz/modules/
@@ -1,3 +1,5 @@

class << self
def include(*mods)
@@ -3,11 +3,8 @@ fails:Kernel#eval evaluates within the scope of the eval
fails:Kernel#eval evaluates such that consts are scoped to the class of the eval
fails:Kernel#eval updates a local in a scope above when modified in a nested block scope
fails:Kernel#eval does not share locals across eval scopes
fails:Kernel#eval doesn't accept a Proc object as a binding
fails:Kernel#eval does not make Proc locals visible to evaluated code
fails:Kernel#eval allows a binding to be captured inside an eval
fails:Kernel#eval allows creating a new class in a binding
fails:Kernel#eval allows creating a new class in a binding created by #eval
fails:Kernel#eval includes file and line information in syntax error
fails:Kernel#eval sets constants at the toplevel from inside a block
fails:Kernel#eval uses the filename of the binding if none is provided

This file was deleted.

@@ -10,6 +10,7 @@
from topaz.error import RubyError, error_for_oserror
from topaz.module import Module, ModuleDef
from topaz.modules.process import Process
from topaz.objects.bindingobject import W_BindingObject
from topaz.objects.exceptionobject import W_ExceptionObject
from topaz.objects.procobject import W_ProcObject
from topaz.objects.stringobject import W_StringObject
@@ -305,9 +306,15 @@ def method_instance_of(self, space, w_mod):
return space.newbool(space.getnonsingletonclass(self) is w_mod)

def method_eval(self, space, w_source):
frame = space.getexecutioncontext().gettoprubyframe()
w_binding = space.newbinding_fromframe(frame)
def method_eval(self, space, w_source, w_binding=None):
if w_binding is None:
frame = space.getexecutioncontext().gettoprubyframe()
w_binding = space.newbinding_fromframe(frame)
elif not isinstance(w_binding, W_BindingObject):
raise space.error(space.w_TypeError,
"wrong argument type %s (expected Binding)" %
return space.send(w_binding, space.newsymbol("eval"), [w_source])


0 comments on commit 4dff199

Please sign in to comment.