diff options
Diffstat (limited to 'spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb')
-rw-r--r-- | spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb b/spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb new file mode 100644 index 0000000000..862480cd02 --- /dev/null +++ b/spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb @@ -0,0 +1,26 @@ +require_relative '../../../spec_helper' + +ruby_version_is "3.3" do + describe "ObjectSpace::WeakKeyMap#[]" do + it "is faithful to the map's content" do + map = ObjectSpace::WeakKeyMap.new + key1, key2 = %w[a b].map(&:upcase) + ref1, ref2 = %w[x y] + map[key1] = ref1 + map[key1].should == ref1 + map[key1] = ref1 + map[key1].should == ref1 + map[key2] = ref2 + map[key1].should == ref1 + map[key2].should == ref2 + end + + it "matches using equality semantics" do + map = ObjectSpace::WeakKeyMap.new + key1, key2 = %w[a a].map(&:upcase) + ref = "x" + map[key1] = ref + map[key2].should == ref + end + end +end |