Debian Codegraph @

test/-ext-/proc/test_bmethod.rb

raw
1 # frozen_string_literal: false
2 require 'test/unit'
3 require '-test-/proc'
4
5 class Test_Proc < Test::Unit::TestCase
6 class TestBMethod < Test::Unit::TestCase
7 end
8 end
9
10 class Test_Proc::TestBMethod
11 class Base
12 def foo(*a)
13 a
14 end
15 end
16
17 class Bound < Base
18 define_method(:foo, Bug::Proc.make_call_super(42))
19 define_method(:receiver, Bug::Proc.make_call_receiver(nil))
20 end
21
22 def test_super_in_bmethod
23 obj = Bound.new
24 assert_equal([1, 42], obj.foo(1))
25 end
26
27 def test_block_super
28 obj = Bound.new
29 result = nil
30 obj.foo(2) {|*a| result = a}
31 assert_equal([2, 42], result)
32 end
33
34 def test_receiver_in_bmethod
35 obj = Bound.new
36 assert_same(obj, obj.receiver)
37 end
38 end