PageRenderTime 42ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://bitbucket.org/mediashelf/fedora-migrator
Ruby | 26 lines | 20 code | 4 blank | 2 comment | 0 complexity | 2a8f2ae4850dc8b6ba81f22ad9705482 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/bind.rb'
  2. require 'test/unit'
  3. class TestProc < Test::Unit::TestCase
  4. # Not sure why this is thread critical?
  5. def test_memory_leak
  6. a = 2
  7. tproc = lambda { |x| x + a }
  8. 99.times {
  9. tmethod = tproc.bind(self) #to_method
  10. assert_equal( 3, tmethod.call(1) )
  11. }
  12. meths = (
  13. Object.instance_methods +
  14. Object.public_instance_methods +
  15. Object.private_instance_methods +
  16. Object.protected_instance_methods
  17. )
  18. meths = meths.select{ |s| s.to_s =~ /^_bind_/ }
  19. #meths = Symbol.all_symbols.select { |s| s.to_s =~ /^_bind_/ } # why?
  20. assert_equal( 0, meths.size )
  21. end
  22. end