summaryrefslogtreecommitdiff
path: root/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2022-03-28 17:47:04 +0200
committerBenoit Daloze <eregontp@gmail.com>2022-03-28 17:47:04 +0200
commit8db4f25bf4327f169902afd9ea8f4b03b65656f0 (patch)
treead61b99fb2d5ebfe9c07de8c2b5885e80d20b8e1 /spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
parentae650f0372e10cea4d695769b1fcdc23a76fdf17 (diff)
Update to ruby/spec@aaf998f
Diffstat (limited to 'spec/ruby/core/hash/ruby2_keywords_hash_spec.rb')
-rw-r--r--spec/ruby/core/hash/ruby2_keywords_hash_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb b/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
index 005886a482..13e8ffe4af 100644
--- a/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
+++ b/spec/ruby/core/hash/ruby2_keywords_hash_spec.rb
@@ -40,6 +40,20 @@ ruby_version_is "2.7" do
kw.should == h
end
+ it "copies instance variables" do
+ h = {a: 1}
+ h.instance_variable_set(:@foo, 42)
+ kw = Hash.ruby2_keywords_hash(h)
+ kw.instance_variable_get(:@foo).should == 42
+ end
+
+ it "copies the hash internals" do
+ h = {a: 1}
+ kw = Hash.ruby2_keywords_hash(h)
+ h[:a] = 2
+ kw[:a].should == 1
+ end
+
it "raises TypeError for non-Hash" do
-> { Hash.ruby2_keywords_hash(nil) }.should raise_error(TypeError)
end