Remove codes for unsupported Ruby (#17353)

Protocol Buffers  only supports Ruby >= 3.0 since 360531cd08

Closes #17353

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/17353 from y-yagi:remove_codes_for_ruby27 80571a4389
PiperOrigin-RevId: 658528987
pull/17696/head
y-yagi 8 months ago committed by Copybara-Service
parent 258f3e9763
commit 184f3a37e9
  1. 4
      ruby/tests/gc_test.rb
  2. 20
      ruby/tests/repeated_field_test.rb

@ -4,9 +4,7 @@
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
old_gc = GC.stress
# Ruby 2.7.0 - 2.7.1 has a GC bug in its parser, so turn off stress for now
# See https://bugs.ruby-lang.org/issues/16807
GC.stress = 0x01 | 0x04 unless RUBY_VERSION.match?(/^2\.7\./)
GC.stress = 0x01 | 0x04
require 'generated_code_pb'
require 'generated_code_proto2_pb'
GC.stress = old_gc

@ -215,28 +215,16 @@ class RepeatedFieldTest < Test::Unit::TestCase
arr[-5..-1]
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Infinite range; introduce in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[0..]"
end
eval "arr[0..]"
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Beginless range; introduced in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[..-1]"
end
eval "arr[..-1]"
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Infinite range; introduce in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[0...]" # Exclusive range
end
eval "arr[0...]" # Exclusive range
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
# Beginless range; introduced in Ruby 2.7.
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7')
eval "arr[...-1]" # Exclusive range
end
eval "arr[...-1]" # Exclusive range
end
check_self_modifying_method(m.repeated_string, reference_arr) do |arr|
arr[-1, 1]

Loading…
Cancel
Save