Skip to content
Permalink
Browse files

Fix return in define_method

  • Loading branch information
Alex Gaynor
Alex Gaynor committed Apr 28, 2013
1 parent a9150ba commit 335943ee5d4121c1c43f069ce3ac812d5bb3fc88
@@ -1,3 +1,2 @@
fails:Module#class_variables returns an Array with the names of class variables of self
fails:Module#class_variables returns an Array of Symbols of class variable names defined in a metaclass
fails:Module#class_variables returns an Array with names of class variables defined in metaclasses
@@ -1,40 +1,23 @@
fails:passed { |a, b = 1| } creates a method that raises an ArgumentError when passed zero arguments
fails:passed { |a, b = 1| } creates a method that has a default value for b when passed one argument
fails:passed { |a, b = 1| } creates a method that overrides the default argument when passed two arguments
fails:passed { |a, b = 1| } creates a method that raises an ArgumentError when passed three arguments
fails:Module#define_method when given an UnboundMethod passes the given arguments to the new method
fails:Module#define_method when given an UnboundMethod adds the new method to the methods list
fails:Module#define_method calls #method_added after the method is added to the Module
fails:Module#define_method raises a TypeError when the given method is no Method/Proc
fails:Module#define_method raises an ArgumentError when no block is given
fails:Module#define_method raises a RuntimeError if frozen
fails:Module#define_method accepts a String method name
fails:Module#define_method is private
fails:Module#define_method returns a Proc
fails:Module#define_method passed { } creates a method that returns the value computed by the block when passed zero arguments
fails:Module#define_method passed { } creates a method that raises an ArgumentError when passed one argument
fails:Module#define_method passed { } creates a method that raises an ArgumentError when passed two arguments
fails:Module#define_method passed { || } creates a method that returns the value computed by the block when passed zero arguments
fails:Module#define_method passed { || } creates a method that raises an ArgumentError when passed one argument
fails:Module#define_method passed { || } creates a method that raises an ArgumentError when passed two arguments
fails:Module#define_method passed { |a| } creates a method that raises an ArgumentError when passed zero arguments
fails:Module#define_method passed { |a| } creates a method that raises an ArgumentError when passed zero arguments and a block
fails:Module#define_method passed { |a| } creates a method that raises an ArgumentError when passed two arguments
fails:Module#define_method passed { |a| } creates a method that receives the value passed as the argument when passed one argument
fails:Module#define_method passed { |*a| } creates a method that receives an empty array as the argument when passed zero arguments
fails:Module#define_method passed { |*a| } creates a method that receives the value in an array when passed one argument
fails:Module#define_method passed { |*a| } creates a method that receives the values in an array when passed two arguments
fails:Module#define_method passed { |a, *b| } creates a method that raises an ArgumentError when passed zero arguments
fails:Module#define_method passed { |a, *b| } creates a method that returns the value computed by the block when passed one argument
fails:Module#define_method passed { |a, *b| } creates a method that returns the value computed by the block when passed two arguments
fails:Module#define_method passed { |a, *b| } creates a method that returns the value computed by the block when passed three arguments
fails:Module#define_method passed { |a, b| } creates a method that returns the value computed by the block when passed two arguments
fails:Module#define_method passed { |a, b| } creates a method that raises an ArgumentError when passed zero arguments
fails:Module#define_method passed { |a, b| } creates a method that raises an ArgumentError when passed one argument
fails:Module#define_method passed { |a, b| } creates a method that raises an ArgumentError when passed one argument and a block
fails:Module#define_method passed { |a, b| } creates a method that raises an ArgumentError when passed three arguments
fails:Module#define_method passed { |a, b, *c| } creates a method that raises an ArgumentError when passed zero arguments
fails:Module#define_method passed { |a, b, *c| } creates a method that raises an ArgumentError when passed one argument
fails:Module#define_method passed { |a, b, *c| } creates a method that raises an ArgumentError when passed one argument and a block
fails:Module#define_method passed { |a, b, *c| } creates a method that receives an empty array as the third argument when passed two arguments
fails:Module#define_method passed { |a, b, *c| } creates a method that receives the third argument in an array when passed three arguments
@@ -55,8 +55,13 @@ def __init__(self, name, block):
self.block = block

def call(self, space, w_obj, args_w, block):
method_block = self.block.copy(space, w_self=w_obj)
return space.invoke_block(method_block, args_w, block)
from topaz.interpreter import RaiseReturn

method_block = self.block.copy(space, w_self=w_obj, is_lambda=True)
try:
return space.invoke_block(method_block, args_w, block)
except RaiseReturn as e:
return e.w_value

def arity(self, space):
args_count = len(self.block.bytecode.arg_pos) - len(self.block.bytecode.defaults)

0 comments on commit 335943e

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