2015-12-16 00:07:31 -05:00
|
|
|
# frozen_string_literal: false
|
2014-11-09 09:33:19 -05:00
|
|
|
require 'test/unit'
|
|
|
|
require '-test-/proc'
|
|
|
|
|
2018-03-13 02:29:02 -04:00
|
|
|
class Test_Proc < Test::Unit::TestCase
|
2014-11-09 09:33:19 -05:00
|
|
|
class TestBMethod < Test::Unit::TestCase
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-13 02:29:02 -04:00
|
|
|
class Test_Proc::TestBMethod
|
2014-11-09 09:33:19 -05:00
|
|
|
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
|