PageRenderTime 48ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/test/-ext-/proc/test_bmethod.rb

http://github.com/ruby/ruby
Ruby | 38 lines | 31 code | 6 blank | 1 comment | 0 complexity | a0e77cbb0b4fcd03480a6ee7cbfd9d69 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-3.0
  1. # frozen_string_literal: false
  2. require 'test/unit'
  3. require '-test-/proc'
  4. class Test_Proc < Test::Unit::TestCase
  5. class TestBMethod < Test::Unit::TestCase
  6. end
  7. end
  8. class Test_Proc::TestBMethod
  9. class Base
  10. def foo(*a)
  11. a
  12. end
  13. end
  14. class Bound < Base
  15. define_method(:foo, Bug::Proc.make_call_super(42))
  16. define_method(:receiver, Bug::Proc.make_call_receiver(nil))
  17. end
  18. def test_super_in_bmethod
  19. obj = Bound.new
  20. assert_equal([1, 42], obj.foo(1))
  21. end
  22. def test_block_super
  23. obj = Bound.new
  24. result = nil
  25. obj.foo(2) {|*a| result = a}
  26. assert_equal([2, 42], result)
  27. end
  28. def test_receiver_in_bmethod
  29. obj = Bound.new
  30. assert_same(obj, obj.receiver)
  31. end
  32. end