Sha256: 648e5d59801c37c5e5b58512f92a339b0b469ba589ffc5a182dce4fd440c33fd

Contents?: true

Size: 1.13 KB

Versions: 10

Compression:

Stored size: 1.13 KB

Contents

  #  _____         _
  # |_   _|__  ___| |_
  #   | |/ _ \/ __| __|
  #   | |  __/\__ \ |
  #   |_|\___||___/\__|
  #
  # for lib/facets/proc/bind.rb
  #
  # Extracted Mon Sep 03 16:23:07 -0700 2007
  # w/ Test Extraction Ratchet
  #

 require 'facets/proc/bind.rb'



  require 'test/unit'

  class TestProc < 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

    # Not sure why this is thread critical?

    def test_memory_leak
      a = 2
      tproc = lambda { |x| x + a }
      99.times {
        tmethod = tproc.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



Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.0.0 test/unit/proc/test_bind.rb
facets-2.0.1 test/unit/proc/test_bind.rb
facets-2.0.2 test/unit/proc/test_bind.rb
facets-2.1.0 test/unit/proc/test_bind.rb
facets-2.1.1 test/unit/proc/test_bind.rb
facets-2.1.2 test/unit/proc/test_bind.rb
facets-2.0.3 test/unit/proc/test_bind.rb
facets-2.0.4 test/unit/proc/test_bind.rb
facets-2.0.5 test/unit/proc/test_bind.rb
facets-2.1.3 test/unit/proc/test_bind.rb