Sha256: d0d6be0ac3d1043b8792c4bfeaafb4b0985022b9b1bbcae8583a1651b2504eda
Contents?: true
Size: 540 Bytes
Versions: 5
Compression:
Stored size: 540 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 ) end end
Version data entries
5 entries across 5 versions & 1 rubygems