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
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu, macos, windows ]
ruby: [ 3.2.9, 3.3.10, 3.4.8, 4.0.1 ]
ruby: [ 3.3.10, 3.4.8, 4.0.1 ]
mspecopt: [""]
rubyopt: [""]
exclude:
- { os: windows, ruby: 3.2.9 } # 3.2.9 has some issue with file time microseconds
include:
- { os: windows, ruby: 3.2.8 } # 3.2.9 has some issue with file time microseconds
- { os: ubuntu, ruby: 4.0.1, mspecopt: "--repeat 2" }
- { os: ubuntu, ruby: 4.0.1, rubyopt: "--enable-frozen-string-literal" }
- { os: ubuntu, ruby: 4.0.1, rubyopt: "--parser=parse.y" }
Expand Down
1 change: 1 addition & 0 deletions 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
10 changes: 2 additions & 8 deletions 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
18 changes: 4 additions & 14 deletions 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 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 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 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
18 changes: 4 additions & 14 deletions core/array/pack/shared/unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,10 @@
-> { [obj].pack("U") }.should raise_error(TypeError)
end

ruby_version_is ""..."3.3" do
it "ignores NULL bytes between directives" do
suppress_warning do
[1, 2, 3].pack("U\x00U").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("U\x00U")
}.should raise_error(ArgumentError, /unknown pack directive/)
end
it "raise ArgumentError for NULL bytes between directives" do
-> {
[1, 2, 3].pack("U\x00U")
}.should raise_error(ArgumentError, /unknown pack directive/)
end

it "ignores spaces between directives" do
Expand Down
Loading