Skip to content

Commit 58cc138

Browse files
kojix2kou
authored andcommitted
Fix step behavior for beginless ranges in Ruby 3.4+
See ruby/ruby#7444
1 parent 61ba3ef commit 58cc138

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

spec/pycall/pyobject_wrapper_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ module PyCall
162162
expect(list[(1..-1).step(2)]).to eq(PyCall::List.new([2, 4, 6, 8, 10]))
163163
expect(list[(1..-2).step(2)]).to eq(PyCall::List.new([2, 4, 6, 8]))
164164
expect(list[(-1..0).step(-1)]).to eq(PyCall::List.new([*1..10].reverse))
165-
expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse))
165+
# In Ruby 3.4+, step for non-numeric beginless ranges raises ArgumentError
166+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.4.0')
167+
expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse))
168+
end
166169
expect(list[(-1...0).step(-1)]).to eq(PyCall::List.new([*2..10].reverse))
167170
expect(list[(-2..2).step(-2)]).to eq(PyCall::List.new([9, 7, 5, 3]))
168171
expect(list[(-2...2).step(-2)]).to eq(PyCall::List.new([9, 7, 5]))

0 commit comments

Comments
 (0)