Sha256: dbb8a49ecee74dc045c499f2516689a66571aba3d986a639f1a44439c76a68f4

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
# for lib/facets/core/proc/to_method.rb
#
# Extracted Tue Jul 25 10:07:15 EDT 2006
# Unit Tools Reap Test Extractor
#

require 'facets/core/proc/to_method.rb'


  require 'test/unit'

  class TCProc < Test::Unit::TestCase

    def test_to_method
      a = 2
      tproc = proc { |x| x + a }
      tmethod = tproc.to_method(:tryit)
      assert_equal( 3, tmethod.call(1) )
      assert_respond_to( self, :tryit )
      assert_equal( 3, tryit(1) )
    end

    # This is dependent on other tests! Be aware!

    def test_memory_leak
      a = 2
      tproc = proc { |x| x + a }
      100.times {
        tmethod = tproc.to_method
        assert_equal( 3, tmethod.call(1) )
      }
      meths = Symbol.all_symbols.select { |s| s.to_s =~ /^__to_method/ }
      assert_equal( 1, meths.size )
    end

  end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-1.7.0 test/lib/facets/core/proc/test_to_method.rb