Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f2db2fee5a
Fetching contributors…

Cannot retrieve contributors at this time

25 lines (24 sloc) 0.828 kB
$: << File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib')
require 'algorithms'
if defined? Containers::CRBTreeMap
describe "CRBTreeMap" do
it "should mark ruby object references" do
anon_key_class = Class.new do
attr :value
def initialize(x); @value = x; end
def <=>(other); value <=> other.value; end
end
anon_val_class = Class.new
@tree = Containers::CRBTreeMap.new
100.times { |x| @tree[anon_key_class.new(x)] = anon_val_class.new }
# Mark and sweep
ObjectSpace.garbage_collect
# Check if any instances were swept
count = 0
ObjectSpace.each_object(anon_key_class) { |x| count += 1 }
count.should eql(100)
ObjectSpace.each_object(anon_val_class) { |x| count += 1 }
count.should eql(200)
end
end
end
Jump to Line
Something went wrong with that request. Please try again.