Sha256: b7f68ffb069113d6cbef38efef082a49b8589f04c9156b1bb5bfed1d9c832765

Contents?: true

Size: 820 Bytes

Versions: 2

Compression:

Stored size: 820 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "Wref" do
  it "should not fail" do
    #This test does not work under JRuby.
    if RUBY_ENGINE != "jruby"
      str = "Test"
      ref = Wref.new(str)
      raise "Should have been alive but wasnt." if !ref.alive?
      str = nil
      
      #In MRI we have to define another object finalizer, before the last will be finalized.
      str2 = "Test 2"
      ref2 = Wref.new(str2)
      ref2 = nil
      GC.start
      raise "Should have been GCed but wasnt." if ref.alive?
      
      
      str = "Test"
      map = Wref_map.new
      map[5] = str
      raise "Should have been valid but wasnt." if !map.valid?(5)
      str = nil
      GC.start
      raise "Should habe been garbage collected but wasnt." if !map.valid?(5)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wref-0.0.2 spec/wref_spec.rb
wref-0.0.1 spec/wref_spec.rb