2014-11-09 09:33:19 -05:00
|
|
|
require 'test/unit'
|
|
|
|
require '-test-/proc'
|
|
|
|
|
|
|
|
class TestProc < Test::Unit::TestCase
|
|
|
|
class TestBMethod < Test::Unit::TestCase
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class TestProc::TestBMethod
|
|
|
|
class Base
|
|
|
|
def foo(*a)
|
|
|
|
a
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Bound < Base
|
2014-11-16 05:11:28 -05:00
|
|
|
define_method(:foo, Bug::Proc.make_call_super(42))
|
2014-11-16 05:38:15 -05:00
|
|
|
define_method(:receiver, Bug::Proc.make_call_receiver(nil))
|
2014-11-09 09:33:19 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_super_in_bmethod
|
|
|
|
obj = Bound.new
|
|
|
|
assert_equal([1, 42], obj.foo(1))
|
|
|
|
end
|
2014-11-09 09:58:33 -05:00
|
|
|
|
|
|
|
def test_block_super
|
|
|
|
obj = Bound.new
|
|
|
|
result = nil
|
|
|
|
obj.foo(2) {|*a| result = a}
|
|
|
|
assert_equal([2, 42], result)
|
|
|
|
end
|
2014-11-16 05:38:15 -05:00
|
|
|
|
|
|
|
def test_receiver_in_bmethod
|
|
|
|
obj = Bound.new
|
|
|
|
assert_same(obj, obj.receiver)
|
|
|
|
end
|
2014-11-09 09:33:19 -05:00
|
|
|
end
|