diff options
Diffstat (limited to 'spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb')
| -rw-r--r-- | spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb b/spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb new file mode 100644 index 0000000000..b6bb469158 --- /dev/null +++ b/spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb @@ -0,0 +1,19 @@ +require_relative '../../../spec_helper' + +describe "ObjectSpace::WeakKeyMap#inspect" do + it "only displays size in output" do + map = ObjectSpace::WeakKeyMap.new + key1, key2, key3 = "foo", "bar", "bar" + map.inspect.should =~ /\A\#<ObjectSpace::WeakKeyMap:0x\h+ size=0>\z/ + map[key1] = 1 + map.inspect.should =~ /\A\#<ObjectSpace::WeakKeyMap:0x\h+ size=1>\z/ + map[key2] = 2 + map.inspect.should =~ /\A\#<ObjectSpace::WeakKeyMap:0x\h+ size=2>\z/ + map[key3] = 3 + map.inspect.should =~ /\A\#<ObjectSpace::WeakKeyMap:0x\h+ size=2>\z/ + + key1.should == "foo" # keep the key alive until here to keep the map entry + key2.should == "bar" # keep the key alive until here to keep the map entry + key3.should == "bar" # keep the key alive until here to keep the map entry + end +end |
