aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core
diff options
context:
space:
mode:
authorKenichi Kamiya <kachick1@gmail.com>2021-03-28 09:14:57 +0900
committerGitHub <noreply@github.com>2021-03-28 09:14:57 +0900
commit31e0382723bfb35cffe3ca485dd0577668cafa07 (patch)
tree09d09fa724f0a0ea6f47b7d13328c00c18b5bc97 /spec/ruby/core
parente398a0e53a7207152fb2139f1e4485968a07f9de (diff)
downloadruby-31e0382723bfb35cffe3ca485dd0577668cafa07.tar.gz
Keep non evaluated keys in `Hash#transform_keys!` [Bug #17735]
Diffstat (limited to 'spec/ruby/core')
-rw-r--r--spec/ruby/core/hash/transform_keys_spec.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/ruby/core/hash/transform_keys_spec.rb b/spec/ruby/core/hash/transform_keys_spec.rb
index 2c5d4124e0..63403a25b0 100644
--- a/spec/ruby/core/hash/transform_keys_spec.rb
+++ b/spec/ruby/core/hash/transform_keys_spec.rb
@@ -84,7 +84,7 @@ describe "Hash#transform_keys!" do
end
end
- ruby_version_is "2.5.1" do
+ ruby_version_is "2.5.1"..."3.1" do
it "returns the processed keys if we broke from the block" do
@hash.transform_keys! do |v|
break if v == :c
@@ -94,6 +94,16 @@ describe "Hash#transform_keys!" do
end
end
+ ruby_version_is "3.1" do
+ it "returns the processed keys and non evaluated keys if we broke from the block" do
+ @hash.transform_keys! do |v|
+ break if v == :c
+ v.succ
+ end
+ @hash.should == { b: 1, c: 2, d: 4 }
+ end
+ end
+
it "keeps later pair if new keys conflict" do
@hash.transform_keys! { |_| :a }.should == { a: 4 }
end