PageRenderTime 38ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/gems/facets-2.4.5/test/core/proc/test_to_method.rb

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 26 lines | 19 code | 7 blank | 0 comment | 0 complexity | 5c4623a78bf9d37bcbf903ebf4d10937 MD5 | raw file
Possible License(s): GPL-3.0, GPL-2.0, IPL-1.0, AGPL-1.0, LGPL-3.0
  1. require 'facets/proc/to_method.rb'
  2. require 'test/unit'
  3. class TestProc < Test::Unit::TestCase
  4. def test_to_method
  5. a = 2
  6. tproc = proc { |x| x + a }
  7. tmeth = tproc.to_method(self, :tryit)
  8. assert_equal( 3, tmeth.call(1) )
  9. assert_respond_to( self, :tryit )
  10. assert_equal( 3, tryit(1) )
  11. end
  12. def test_to_method_with_immutable
  13. tproc = proc{ self }
  14. tmeth = tproc.to_method(:foo, :tryit)
  15. assert_equal(:foo, tmeth.call)
  16. assert_respond_to( :foo, :tryit )
  17. assert_equal( :foo, :foo.tryit(1) )
  18. end
  19. end