Skip to content
This repository
tag: 1.5.0.RC3
Fetching contributors…

Cannot retrieve contributors at this time

file 26 lines (21 sloc) 0.482 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
require 'test/unit'
require 'weakref'
require 'java'

class TestThreadContextFrameDereferencesUnreachableVariables < Test::Unit::TestCase

  def test_dereference_unreachable_variable
    o = 'foo'
    o = WeakRef.new(o)
    poll do
      java.lang.System.gc
      !o.weakref_alive?
    end
    assert !o.weakref_alive?, "object was not collected"
  end

  private

  def poll(seconds=1.0)
    (seconds * 10).to_i.times do
      return if yield
      sleep 0.1
    end
  end

end
Something went wrong with that request. Please try again.