Skip to content

[GR-14806] Update ruby/specs #3864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ local part_definitions = {
"CHECK_LEAKS": "true",
"RUBY_SPEC_TEST_ZLIB_CRC_TABLE": "false", # CRuby was built on OL6 and is used on OL7
},
run+: jt(["-u", "ruby", "mspec", "spec/ruby"]) + # 3.2.2
jt(["-u", "/cm/shared/apps-ol7/ruby/3.1.2/bin/ruby", "mspec", "spec/ruby"]),
run+: jt(["-u", "ruby", "mspec", "spec/ruby"]), # 3.2.2
},

test_fast: {
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 3.1
TargetRubyVersion: 3.2
DisplayCopNames: true
Exclude:
- command_line/fixtures/bad_syntax.rb
Expand Down
5 changes: 3 additions & 2 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ ruby/spec is known to be tested in these implementations for every commit:
* [Opal](https://github.com/opal/opal/tree/master/spec)
* [Artichoke](https://github.com/artichoke/spec/tree/artichoke-vendor)

ruby/spec describes the behavior of Ruby 3.1 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (3.1.x, 3.2.x, etc), and those are tested in CI.
ruby/spec describes the behavior of Ruby 3.2 and more recent Ruby versions.
More precisely, every latest stable MRI release should [pass](https://github.com/ruby/spec/actions/workflows/ci.yml) all specs of ruby/spec (3.2.x, 3.3.x, etc), and those are tested in CI.

### Synchronization with Ruby Implementations

Expand Down Expand Up @@ -63,6 +63,7 @@ For older specs try these commits:
* Ruby 2.6.10 - [Suite](https://github.com/ruby/spec/commit/aaf998fb8c92c4e63ad423a2e7ca6e6921818c6e) using [MSpec](https://github.com/ruby/mspec/commit/5e36c684e9e2b92b1187589bba1df22c640a8661)
* Ruby 2.7.8 - [Suite](https://github.com/ruby/spec/commit/93787e6035c925b593a9c0c6fb0e7e07a6f1df1f) using [MSpec](https://github.com/ruby/mspec/commit/1d8cf64722d8a7529f7cd205be5f16a89b7a67fd)
* Ruby 3.0.7 - [Suite](https://github.com/ruby/spec/commit/affef93d9940f615e4836f64b011da211f570913) using [MSpec](https://github.com/ruby/mspec/commit/0aabb3e548eb5ea6cad0125f8f46cee34542b6b7)
* Ruby 3.1.6 - [Suite](https://github.com/ruby/spec/commit/ec960f2389d1c2265d32397fa8afa6d462014efc) using [MSpec](https://github.com/ruby/mspec/commit/484310dbed35b84c74484fd674602f88c42d063a)

### Running the specs

Expand Down
13 changes: 13 additions & 0 deletions spec/ruby/command_line/dash_0_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require_relative '../spec_helper'

describe "The -0 command line option" do
it "sets $/ and $-0" do
ruby_exe("puts $/, $-0", options: "-072").should == ":\n:\n"
end

ruby_version_is "3.5" do
it "sets $/ and $-0 as a frozen string" do
ruby_exe("puts $/.frozen?, $-0.frozen?", options: "-072").should == "true\ntrue\n"
end
end
end
4 changes: 2 additions & 2 deletions spec/ruby/core/array/pack/a_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
["abc"].pack("A*").should == "abc"
end

it "padds the output with spaces when the count exceeds the size of the String" do
it "pads the output with spaces when the count exceeds the size of the String" do
["abc"].pack("A6").should == "abc "
end

Expand Down Expand Up @@ -55,7 +55,7 @@
["abc"].pack("a*").should == "abc"
end

it "padds the output with NULL bytes when the count exceeds the size of the String" do
it "pads the output with NULL bytes when the count exceeds the size of the String" do
["abc"].pack("a6").should == "abc\x00\x00\x00"
end

Expand Down
11 changes: 1 addition & 10 deletions spec/ruby/core/array/pack/shared/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@
[@obj, @obj, @obj, @obj].pack("aa #{pack_format} # some comment \n#{pack_format}").should be_an_instance_of(String)
end

ruby_version_is ""..."3.2" do
it "warns in verbose mode that a directive is unknown" do
# additional directive ('a') is required for the X directive
-> { [@obj, @obj].pack("a R" + pack_format) }.should complain(/unknown pack directive 'R'/, verbose: true)
-> { [@obj, @obj].pack("a 0" + pack_format) }.should complain(/unknown pack directive '0'/, verbose: true)
-> { [@obj, @obj].pack("a :" + pack_format) }.should complain(/unknown pack directive ':'/, verbose: true)
end
end

ruby_version_is "3.2"..."3.3" do
ruby_version_is ""..."3.3" do
# https://bugs.ruby-lang.org/issues/19150
# NOTE: it's just a plan of the Ruby core team
it "warns that a directive is unknown" do
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/core/array/pack/z_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
["abc"].pack("Z*").should == "abc\x00"
end

it "padds the output with NULL bytes when the count exceeds the size of the String" do
it "pads the output with NULL bytes when the count exceeds the size of the String" do
["abc"].pack("Z6").should == "abc\x00\x00\x00"
end

Expand Down
184 changes: 91 additions & 93 deletions spec/ruby/core/array/shared/slice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -754,99 +754,97 @@ def to.to_int() -2 end
a.send(@method, (...-9)).should == []
end

ruby_version_is "3.2" do
describe "can be sliced with Enumerator::ArithmeticSequence" do
it "with infinite/inverted ranges and negative steps" do
@array = [0, 1, 2, 3, 4, 5]
@array.send(@method, (2..).step(-1)).should == [2, 1, 0]
@array.send(@method, (2..).step(-2)).should == [2, 0]
@array.send(@method, (2..).step(-3)).should == [2]
@array.send(@method, (2..).step(-4)).should == [2]

@array.send(@method, (-3..).step(-1)).should == [3, 2, 1, 0]
@array.send(@method, (-3..).step(-2)).should == [3, 1]
@array.send(@method, (-3..).step(-3)).should == [3, 0]
@array.send(@method, (-3..).step(-4)).should == [3]
@array.send(@method, (-3..).step(-5)).should == [3]

@array.send(@method, (..0).step(-1)).should == [5, 4, 3, 2, 1, 0]
@array.send(@method, (..0).step(-2)).should == [5, 3, 1]
@array.send(@method, (..0).step(-3)).should == [5, 2]
@array.send(@method, (..0).step(-4)).should == [5, 1]
@array.send(@method, (..0).step(-5)).should == [5, 0]
@array.send(@method, (..0).step(-6)).should == [5]
@array.send(@method, (..0).step(-7)).should == [5]

@array.send(@method, (...0).step(-1)).should == [5, 4, 3, 2, 1]
@array.send(@method, (...0).step(-2)).should == [5, 3, 1]
@array.send(@method, (...0).step(-3)).should == [5, 2]
@array.send(@method, (...0).step(-4)).should == [5, 1]
@array.send(@method, (...0).step(-5)).should == [5]
@array.send(@method, (...0).step(-6)).should == [5]

@array.send(@method, (...1).step(-1)).should == [5, 4, 3, 2]
@array.send(@method, (...1).step(-2)).should == [5, 3]
@array.send(@method, (...1).step(-3)).should == [5, 2]
@array.send(@method, (...1).step(-4)).should == [5]
@array.send(@method, (...1).step(-5)).should == [5]

@array.send(@method, (..-5).step(-1)).should == [5, 4, 3, 2, 1]
@array.send(@method, (..-5).step(-2)).should == [5, 3, 1]
@array.send(@method, (..-5).step(-3)).should == [5, 2]
@array.send(@method, (..-5).step(-4)).should == [5, 1]
@array.send(@method, (..-5).step(-5)).should == [5]
@array.send(@method, (..-5).step(-6)).should == [5]

@array.send(@method, (...-5).step(-1)).should == [5, 4, 3, 2]
@array.send(@method, (...-5).step(-2)).should == [5, 3]
@array.send(@method, (...-5).step(-3)).should == [5, 2]
@array.send(@method, (...-5).step(-4)).should == [5]
@array.send(@method, (...-5).step(-5)).should == [5]

@array.send(@method, (4..1).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (4..1).step(-2)).should == [4, 2]
@array.send(@method, (4..1).step(-3)).should == [4, 1]
@array.send(@method, (4..1).step(-4)).should == [4]
@array.send(@method, (4..1).step(-5)).should == [4]

@array.send(@method, (4...1).step(-1)).should == [4, 3, 2]
@array.send(@method, (4...1).step(-2)).should == [4, 2]
@array.send(@method, (4...1).step(-3)).should == [4]
@array.send(@method, (4...1).step(-4)).should == [4]

@array.send(@method, (-2..1).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (-2..1).step(-2)).should == [4, 2]
@array.send(@method, (-2..1).step(-3)).should == [4, 1]
@array.send(@method, (-2..1).step(-4)).should == [4]
@array.send(@method, (-2..1).step(-5)).should == [4]

@array.send(@method, (-2...1).step(-1)).should == [4, 3, 2]
@array.send(@method, (-2...1).step(-2)).should == [4, 2]
@array.send(@method, (-2...1).step(-3)).should == [4]
@array.send(@method, (-2...1).step(-4)).should == [4]

@array.send(@method, (4..-5).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (4..-5).step(-2)).should == [4, 2]
@array.send(@method, (4..-5).step(-3)).should == [4, 1]
@array.send(@method, (4..-5).step(-4)).should == [4]
@array.send(@method, (4..-5).step(-5)).should == [4]

@array.send(@method, (4...-5).step(-1)).should == [4, 3, 2]
@array.send(@method, (4...-5).step(-2)).should == [4, 2]
@array.send(@method, (4...-5).step(-3)).should == [4]
@array.send(@method, (4...-5).step(-4)).should == [4]

@array.send(@method, (-2..-5).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (-2..-5).step(-2)).should == [4, 2]
@array.send(@method, (-2..-5).step(-3)).should == [4, 1]
@array.send(@method, (-2..-5).step(-4)).should == [4]
@array.send(@method, (-2..-5).step(-5)).should == [4]

@array.send(@method, (-2...-5).step(-1)).should == [4, 3, 2]
@array.send(@method, (-2...-5).step(-2)).should == [4, 2]
@array.send(@method, (-2...-5).step(-3)).should == [4]
@array.send(@method, (-2...-5).step(-4)).should == [4]
end
describe "can be sliced with Enumerator::ArithmeticSequence" do
it "with infinite/inverted ranges and negative steps" do
@array = [0, 1, 2, 3, 4, 5]
@array.send(@method, (2..).step(-1)).should == [2, 1, 0]
@array.send(@method, (2..).step(-2)).should == [2, 0]
@array.send(@method, (2..).step(-3)).should == [2]
@array.send(@method, (2..).step(-4)).should == [2]

@array.send(@method, (-3..).step(-1)).should == [3, 2, 1, 0]
@array.send(@method, (-3..).step(-2)).should == [3, 1]
@array.send(@method, (-3..).step(-3)).should == [3, 0]
@array.send(@method, (-3..).step(-4)).should == [3]
@array.send(@method, (-3..).step(-5)).should == [3]

@array.send(@method, (..0).step(-1)).should == [5, 4, 3, 2, 1, 0]
@array.send(@method, (..0).step(-2)).should == [5, 3, 1]
@array.send(@method, (..0).step(-3)).should == [5, 2]
@array.send(@method, (..0).step(-4)).should == [5, 1]
@array.send(@method, (..0).step(-5)).should == [5, 0]
@array.send(@method, (..0).step(-6)).should == [5]
@array.send(@method, (..0).step(-7)).should == [5]

@array.send(@method, (...0).step(-1)).should == [5, 4, 3, 2, 1]
@array.send(@method, (...0).step(-2)).should == [5, 3, 1]
@array.send(@method, (...0).step(-3)).should == [5, 2]
@array.send(@method, (...0).step(-4)).should == [5, 1]
@array.send(@method, (...0).step(-5)).should == [5]
@array.send(@method, (...0).step(-6)).should == [5]

@array.send(@method, (...1).step(-1)).should == [5, 4, 3, 2]
@array.send(@method, (...1).step(-2)).should == [5, 3]
@array.send(@method, (...1).step(-3)).should == [5, 2]
@array.send(@method, (...1).step(-4)).should == [5]
@array.send(@method, (...1).step(-5)).should == [5]

@array.send(@method, (..-5).step(-1)).should == [5, 4, 3, 2, 1]
@array.send(@method, (..-5).step(-2)).should == [5, 3, 1]
@array.send(@method, (..-5).step(-3)).should == [5, 2]
@array.send(@method, (..-5).step(-4)).should == [5, 1]
@array.send(@method, (..-5).step(-5)).should == [5]
@array.send(@method, (..-5).step(-6)).should == [5]

@array.send(@method, (...-5).step(-1)).should == [5, 4, 3, 2]
@array.send(@method, (...-5).step(-2)).should == [5, 3]
@array.send(@method, (...-5).step(-3)).should == [5, 2]
@array.send(@method, (...-5).step(-4)).should == [5]
@array.send(@method, (...-5).step(-5)).should == [5]

@array.send(@method, (4..1).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (4..1).step(-2)).should == [4, 2]
@array.send(@method, (4..1).step(-3)).should == [4, 1]
@array.send(@method, (4..1).step(-4)).should == [4]
@array.send(@method, (4..1).step(-5)).should == [4]

@array.send(@method, (4...1).step(-1)).should == [4, 3, 2]
@array.send(@method, (4...1).step(-2)).should == [4, 2]
@array.send(@method, (4...1).step(-3)).should == [4]
@array.send(@method, (4...1).step(-4)).should == [4]

@array.send(@method, (-2..1).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (-2..1).step(-2)).should == [4, 2]
@array.send(@method, (-2..1).step(-3)).should == [4, 1]
@array.send(@method, (-2..1).step(-4)).should == [4]
@array.send(@method, (-2..1).step(-5)).should == [4]

@array.send(@method, (-2...1).step(-1)).should == [4, 3, 2]
@array.send(@method, (-2...1).step(-2)).should == [4, 2]
@array.send(@method, (-2...1).step(-3)).should == [4]
@array.send(@method, (-2...1).step(-4)).should == [4]

@array.send(@method, (4..-5).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (4..-5).step(-2)).should == [4, 2]
@array.send(@method, (4..-5).step(-3)).should == [4, 1]
@array.send(@method, (4..-5).step(-4)).should == [4]
@array.send(@method, (4..-5).step(-5)).should == [4]

@array.send(@method, (4...-5).step(-1)).should == [4, 3, 2]
@array.send(@method, (4...-5).step(-2)).should == [4, 2]
@array.send(@method, (4...-5).step(-3)).should == [4]
@array.send(@method, (4...-5).step(-4)).should == [4]

@array.send(@method, (-2..-5).step(-1)).should == [4, 3, 2, 1]
@array.send(@method, (-2..-5).step(-2)).should == [4, 2]
@array.send(@method, (-2..-5).step(-3)).should == [4, 1]
@array.send(@method, (-2..-5).step(-4)).should == [4]
@array.send(@method, (-2..-5).step(-5)).should == [4]

@array.send(@method, (-2...-5).step(-1)).should == [4, 3, 2]
@array.send(@method, (-2...-5).step(-2)).should == [4, 2]
@array.send(@method, (-2...-5).step(-3)).should == [4]
@array.send(@method, (-2...-5).step(-4)).should == [4]
end
end

Expand Down
40 changes: 19 additions & 21 deletions spec/ruby/core/class/attached_object_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
require_relative '../../spec_helper'

ruby_version_is '3.2' do
describe "Class#attached_object" do
it "returns the object that is attached to a singleton class" do
a = Class.new
describe "Class#attached_object" do
it "returns the object that is attached to a singleton class" do
a = Class.new

a_obj = a.new
a_obj.singleton_class.attached_object.should == a_obj
end
a_obj = a.new
a_obj.singleton_class.attached_object.should == a_obj
end

it "returns the class object that is attached to a class's singleton class" do
a = Class.new
singleton_class = (class << a; self; end)
it "returns the class object that is attached to a class's singleton class" do
a = Class.new
singleton_class = (class << a; self; end)

singleton_class.attached_object.should == a
end
singleton_class.attached_object.should == a
end

it "raises TypeError if the class is not a singleton class" do
a = Class.new
it "raises TypeError if the class is not a singleton class" do
a = Class.new

-> { a.attached_object }.should raise_error(TypeError, /is not a singleton class/)
end
-> { a.attached_object }.should raise_error(TypeError, /is not a singleton class/)
end

it "raises TypeError for special singleton classes" do
-> { nil.singleton_class.attached_object }.should raise_error(TypeError, /[`']NilClass' is not a singleton class/)
-> { true.singleton_class.attached_object }.should raise_error(TypeError, /[`']TrueClass' is not a singleton class/)
-> { false.singleton_class.attached_object }.should raise_error(TypeError, /[`']FalseClass' is not a singleton class/)
end
it "raises TypeError for special singleton classes" do
-> { nil.singleton_class.attached_object }.should raise_error(TypeError, /[`']NilClass' is not a singleton class/)
-> { true.singleton_class.attached_object }.should raise_error(TypeError, /[`']TrueClass' is not a singleton class/)
-> { false.singleton_class.attached_object }.should raise_error(TypeError, /[`']FalseClass' is not a singleton class/)
end
end
31 changes: 0 additions & 31 deletions spec/ruby/core/class/fixtures/callback_order.rb

This file was deleted.

Loading
Loading