summaryrefslogtreecommitdiff
path: root/spec/ruby/core/enumerable
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-20 15:06:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-09-20 15:06:56 +0000
commitabe75149d14d3286d3051c9e961ab6473a243a19 (patch)
treef33ad9fcd4569f51d7f0b85fefb751597211438d /spec/ruby/core/enumerable
parente76eebd79be9fa3cb59d0ea6e4ce8214cc6e56ad (diff)
Enumerable#to_h with block and so on
[Feature #15143] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/enumerable')
-rw-r--r--spec/ruby/core/enumerable/to_h_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/ruby/core/enumerable/to_h_spec.rb b/spec/ruby/core/enumerable/to_h_spec.rb
index 3b712d25d9..966325c736 100644
--- a/spec/ruby/core/enumerable/to_h_spec.rb
+++ b/spec/ruby/core/enumerable/to_h_spec.rb
@@ -43,4 +43,12 @@ describe "Enumerable#to_h" do
enum = EnumerableSpecs::EachDefiner.new([:x])
lambda { enum.to_h }.should raise_error(ArgumentError)
end
+
+ ruby_version_is "2.6" do
+ it "converts [key, value] pairs returned by the block to a hash" do
+ enum = EnumerableSpecs::EachDefiner.new(:a, :b)
+ i = 0
+ enum.to_h {|k| [k, i += 1]}.should == { a: 1, b: 2 }
+ end
+ end
end