Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions spec/mspec/tool/sync/sync-rubyspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,20 @@ def test_new_specs
Dir.chdir(SOURCE_REPO) do
workflow = YAML.load_file(".github/workflows/ci.yml")
job_name = MSPEC ? "test" : "specs"
versions = workflow.dig("jobs", job_name, "strategy", "matrix", "ruby")
versions = workflow.dig("jobs", job_name, "strategy", "matrix", "ruby").map(&:to_s)
versions = versions.grep(/^\d+\./) # Test on MRI
min_version, max_version = versions.minmax

test_command = MSPEC ? "bundle install && bundle exec rspec" : "../mspec/bin/mspec -j"

run_test = -> version {
command = "chruby #{version} && #{test_command}"
command = "chruby ruby-#{version} && #{test_command}"
sh ENV["SHELL"], "-c", command
}

run_test[min_version]
run_test[max_version]
run_test["ruby-master"] if TEST_MASTER
run_test["master"] if TEST_MASTER
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ For older specs try these commits:
* 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)
* Ruby 3.2.9 - [Suite](https://github.com/ruby/spec/commit/97f076242b7fc6e60703e6a6053365065cd6fc30) using [MSpec](https://github.com/ruby/mspec/commit/54704795e21128a930af2021c72c49cb87065134)

### Running the specs

Expand Down
5 changes: 1 addition & 4 deletions spec/ruby/command_line/dash_r_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), options: "-r #{@test_file}", args: "2>&1", exit_status: 1)
$?.should_not.success?
out.should include("REQUIRED")

# it's tempting not to rely on error message and rely only on exception class name,
# but CRuby before 3.2 doesn't print class name for syntax error
out.should include_any_of("syntax error", "SyntaxError")
out.should include("SyntaxError")
end

it "does not require the file if the main script file does not exist" do
Expand Down
10 changes: 2 additions & 8 deletions spec/ruby/command_line/syntax_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
describe "The interpreter" do
it "prints an error when given a file with invalid syntax" do
out = ruby_exe(fixture(__FILE__, "bad_syntax.rb"), args: "2>&1", exit_status: 1)

# it's tempting not to rely on error message and rely only on exception class name,
# but CRuby before 3.2 doesn't print class name for syntax error
out.should include_any_of("syntax error", "SyntaxError")
out.should.include?("SyntaxError")
end

it "prints an error when given code via -e with invalid syntax" do
out = ruby_exe(nil, args: "-e 'a{' 2>&1", exit_status: 1)

# it's tempting not to rely on error message and rely only on exception class name,
# but CRuby before 3.2 doesn't print class name for syntax error
out.should include_any_of("syntax error", "SyntaxError")
out.should.include?("SyntaxError")
end
end
8 changes: 4 additions & 4 deletions spec/ruby/core/array/fetch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
end

it "raises an IndexError if there is no element at index" do
-> { [1, 2, 3].fetch(3) }.should raise_error(IndexError)
-> { [1, 2, 3].fetch(-4) }.should raise_error(IndexError)
-> { [].fetch(0) }.should raise_error(IndexError)
-> { [1, 2, 3].fetch(3) }.should raise_error(IndexError, "index 3 outside of array bounds: -3...3")
-> { [1, 2, 3].fetch(-4) }.should raise_error(IndexError, "index -4 outside of array bounds: -3...3")
-> { [].fetch(0) }.should raise_error(IndexError, "index 0 outside of array bounds: 0...0")
end

it "returns default if there is no element at index if passed a default value" do
Expand Down Expand Up @@ -50,6 +50,6 @@ def o.to_int(); 5; end
end

it "raises a TypeError when the passed argument can't be coerced to Integer" do
-> { [].fetch("cat") }.should raise_error(TypeError)
-> { [].fetch("cat") }.should raise_error(TypeError, "no implicit conversion of String into Integer")
end
end
18 changes: 4 additions & 14 deletions spec/ruby/core/array/pack/c_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,10 @@
[1, 2, 3, 4, 5].pack(pack_format('*')).should == "\x01\x02\x03\x04\x05"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
[1, 2, 3].pack(pack_format("\000", 2)).should == "\x01\x02"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[1, 2, 3].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[1, 2, 3].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down
21 changes: 5 additions & 16 deletions spec/ruby/core/array/pack/shared/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,11 @@
[@obj, @obj, @obj, @obj].pack("aa #{pack_format} # some comment \n#{pack_format}").should be_an_instance_of(String)
end

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

ruby_version_is "3.3" do
it "raise ArgumentError when a directive is unknown" do
# additional directive ('a') is required for the X directive
-> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/)
-> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/)
-> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/)
end
it "raise ArgumentError when a directive is unknown" do
# additional directive ('a') is required for the X directive
-> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/)
-> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/)
-> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/)
end

it "calls #to_str to coerce the directives string" do
Expand Down
72 changes: 16 additions & 56 deletions spec/ruby/core/array/pack/shared/float.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,10 @@
[2.9, 1.4, 8.2].pack(pack_format("*")).should == "\x9a\x999@33\xb3?33\x03A"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
[5.3, 9.2].pack(pack_format("\000", 2)).should == "\x9a\x99\xa9@33\x13A"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -105,20 +95,10 @@
[2.9, 1.4, 8.2].pack(pack_format("*")).should == "@9\x99\x9a?\xb333A\x0333"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
[5.3, 9.2].pack(pack_format("\000", 2)).should == "@\xa9\x99\x9aA\x1333"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -177,20 +157,10 @@
[2.9, 1.4, 8.2].pack(pack_format("*")).should == "333333\x07@ffffff\xf6?ffffff\x20@"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
[5.3, 9.2].pack(pack_format("\000", 2)).should == "333333\x15@ffffff\x22@"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -248,20 +218,10 @@
[2.9, 1.4, 8.2].pack(pack_format("*")).should == "@\x07333333?\xf6ffffff@\x20ffffff"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
[5.3, 9.2].pack(pack_format("\000", 2)).should == "@\x15333333@\x22ffffff"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[5.3, 9.2].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down
114 changes: 24 additions & 90 deletions spec/ruby/core/array/pack/shared/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,10 @@
str.should == "\x78\x65\xcd\xab\x21\x43"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
str.should == "\x78\x65\xcd\xab"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -105,21 +94,10 @@
str.should == "\x65\x78\xab\xcd\x43\x21"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
str.should == "\x65\x78\xab\xcd"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -169,21 +147,10 @@
str.should == "\x78\x65\x43\x12\xcd\xab\xf0\xde\x21\x43\x65\x78"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
str.should == "\x78\x65\x43\x12\xcd\xab\xf0\xde"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -233,21 +200,10 @@
str.should == "\x12\x43\x65\x78\xde\xf0\xab\xcd\x78\x65\x43\x21"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
str = [0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
str.should == "\x12\x43\x65\x78\xde\xf0\xab\xcd"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0x1243_6578, 0xdef0_abcd].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -357,21 +313,10 @@
str.should == "\x56\x78\x12\x34\xcd\xab\xf0\xde\xf0\xde\xba\xdc\x21\x43\x65\x78"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
str = [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2))
str.should == "\x56\x78\x12\x34\xcd\xab\xf0\xde\xf0\xde\xba\xdc\x21\x43\x65\x78"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down Expand Up @@ -429,21 +374,10 @@
str.should == "\xde\xf0\xab\xcd\x34\x12\x78\x56\x78\x65\x43\x21\xdc\xba\xde\xf0"
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
str = [0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2))
str.should == "\xde\xf0\xab\xcd\x34\x12\x78\x56\x78\x65\x43\x21\xdc\xba\xde\xf0"
end
end
end

ruby_version_is "3.3" do
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[0xdef0_abcd_3412_7856, 0x7865_4321_dcba_def0].pack(pack_format("\000", 2))
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down
Loading