summaryrefslogtreecommitdiff
path: root/spec/ruby/core/array
diff options
context:
space:
mode:
authorAndrew Konchin <[email protected]>2024-07-01 15:38:25 +0300
committerBenoit Daloze <[email protected]>2024-07-02 13:33:48 +0200
commitcee62c6738c42ce774e96e180cf2d46afb8e9cbe (patch)
tree52a37ef94e90f99f8471dbba4d6659ca5dc6c532 /spec/ruby/core/array
parentd7af8afe1b85b8de04cd77c673b0f6ef3f3627fa (diff)
Update to ruby/spec@f8987ac
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r--spec/ruby/core/array/each_spec.rb2
-rw-r--r--spec/ruby/core/array/plus_spec.rb2
-rw-r--r--spec/ruby/core/array/to_h_spec.rb6
3 files changed, 8 insertions, 2 deletions
diff --git a/spec/ruby/core/array/each_spec.rb b/spec/ruby/core/array/each_spec.rb
index 57d6082f01..f4b5b758d0 100644
--- a/spec/ruby/core/array/each_spec.rb
+++ b/spec/ruby/core/array/each_spec.rb
@@ -7,7 +7,7 @@ require_relative '../enumerable/shared/enumeratorized'
# Mutating the array while it is being iterated is discouraged as it can result in confusing behavior.
# Yet a Ruby implementation must not crash in such a case, and following the simple CRuby behavior makes sense.
# CRuby simply reads the array storage and checks the size for every iteration;
-# like `i = 0; while i < size; yield self[i]; end`
+# like `i = 0; while i < size; yield self[i]; i += 1; end`
describe "Array#each" do
it "yields each element to the block" do
diff --git a/spec/ruby/core/array/plus_spec.rb b/spec/ruby/core/array/plus_spec.rb
index 635bd131c9..b7153fd3ef 100644
--- a/spec/ruby/core/array/plus_spec.rb
+++ b/spec/ruby/core/array/plus_spec.rb
@@ -21,7 +21,7 @@ describe "Array#+" do
([1, 2, 3] + obj).should == [1, 2, 3, "x", "y"]
end
- it "raises a Typeerror if the given argument can't be converted to an array" do
+ it "raises a TypeError if the given argument can't be converted to an array" do
-> { [1, 2, 3] + nil }.should raise_error(TypeError)
-> { [1, 2, 3] + "abc" }.should raise_error(TypeError)
end
diff --git a/spec/ruby/core/array/to_h_spec.rb b/spec/ruby/core/array/to_h_spec.rb
index f4578211a1..1c814f3d01 100644
--- a/spec/ruby/core/array/to_h_spec.rb
+++ b/spec/ruby/core/array/to_h_spec.rb
@@ -45,6 +45,12 @@ describe "Array#to_h" do
[:a, :b].to_h { |k| [k, k.to_s] }.should == { a: 'a', b: 'b' }
end
+ it "passes to a block each element as a single argument" do
+ ScratchPad.record []
+ [[:a, 1], [:b, 2]].to_h { |*args| ScratchPad << args; [args[0], args[1]] }
+ ScratchPad.recorded.sort.should == [[[:a, 1]], [[:b, 2]]]
+ end
+
it "raises ArgumentError if block returns longer or shorter array" do
-> do
[:a, :b].to_h { |k| [k, k.to_s, 1] }