Sha256: 8f49b00c33f2c7cdf36610906d7ffe7eaabc670c3ed9cda67e019ae9b17e05c6
Contents?: true
Size: 543 Bytes
Versions: 11
Compression:
Stored size: 543 Bytes
Contents
require 'facets/proc/to_method.rb' require 'test/unit' class TestProc < Test::Unit::TestCase def test_to_method a = 2 tproc = proc { |x| x + a } tmeth = tproc.to_method(self, :tryit) assert_equal( 3, tmeth.call(1) ) assert_respond_to( self, :tryit ) assert_equal( 3, tryit(1) ) end def test_to_method_with_immutable tproc = proc{ self } tmeth = tproc.to_method(:foo, :tryit) assert_equal(:foo, tmeth.call) assert_respond_to( :foo, :tryit ) assert_equal( :foo, :foo.tryit(1) ) end end
Version data entries
11 entries across 11 versions & 1 rubygems