Skip to content

Commit cc9a073

Browse files
committed
Fix step behavior for beginless ranges in Ruby 3.4+
See ruby/ruby#7444
1 parent f46d1ad commit cc9a073

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
@@ -161,7 +161,10 @@ module PyCall
161161
list = PyCall::List.new([*1..10])
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]))
164-
expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse))
164+
# In Ruby 3.4+, step for non-numeric beginless ranges raises ArgumentError
165+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.4.0')
166+
expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse))
167+
end
165168
expect(list[(-1..0).step(-1)]).to eq(PyCall::List.new([*1..10].reverse))
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]))

0 commit comments

Comments
 (0)