/vendor/gems/facets-2.4.5/test/core/proc/test_bind.rb
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
- require 'facets/proc/bind.rb'
- require 'test/unit'
- class TestProc < Test::Unit::TestCase
- # Not sure why this is thread critical?
- def test_memory_leak
- a = 2
- tproc = lambda { |x| x + a }
- 99.times {
- tmethod = tproc.bind(self) #to_method
- assert_equal( 3, tmethod.call(1) )
- }
- meths = (
- Object.instance_methods +
- Object.public_instance_methods +
- Object.private_instance_methods +
- Object.protected_instance_methods
- )
- meths = meths.select{ |s| s.to_s =~ /^_bind_/ }
- #meths = Symbol.all_symbols.select { |s| s.to_s =~ /^_bind_/ } # why?
- assert_equal( 0, meths.size )
- end
- end