PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/test/-ext-/method/test_arity.rb

http://github.com/ruby/ruby
Ruby | 38 lines | 32 code | 5 blank | 1 comment | 0 complexity | bdf48adbf9acd3a4d3afb273fe248da8 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, AGPL-3.0
  1. # frozen_string_literal: false
  2. require '-test-/method'
  3. require 'test/unit'
  4. class Test_Method < Test::Unit::TestCase
  5. class TestArity < Test::Unit::TestCase
  6. class A
  7. def foo0()
  8. end
  9. def foom1(*a)
  10. end
  11. def foom2(a,*b)
  12. end
  13. def foo1(a)
  14. end
  15. def foo2(a,b)
  16. end
  17. end
  18. class B < A
  19. private :foo1, :foo2
  20. end
  21. METHODS = {foo0: 0, foo1: 1, foo2: 2, foom1: -1, foom2: -2}
  22. def test_base
  23. METHODS.each do |name, arity|
  24. assert_equal(arity, Bug::Method.mod_method_arity(A, name), "A##{name}")
  25. end
  26. end
  27. def test_zsuper
  28. METHODS.each do |name, arity|
  29. assert_equal(arity, Bug::Method.mod_method_arity(B, name), "B##{name}")
  30. end
  31. end
  32. end
  33. end