Skip to content

Commit 66f03e8

Browse files
committed
1 parent 9ee9146 commit 66f03e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1628
-487
lines changed

spec/ruby/command_line/dash_v_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
ruby_exe(nil, args: '-v').sub("+PRISM ", "").should include(RUBY_DESCRIPTION.sub("+PRISM ", ""))
1010
end unless (defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled?) ||
1111
(defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled?) ||
12+
(ENV['RUBY_GC_LIBRARY'] && ENV['RUBY_GC_LIBRARY'].length > 0) ||
1213
(ENV['RUBY_MN_THREADS'] == '1')
1314
end
1415
end

spec/ruby/command_line/rubyopt_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
guard -> { RbConfig::CONFIG["CROSS_COMPILING"] != "yes" } do
2626
it "prints the version number for '-v'" do
2727
ENV["RUBYOPT"] = '-v'
28-
ruby_exe("").sub("+PRISM ", "")[/\A.*/].should == RUBY_DESCRIPTION.sub("+PRISM ", "")
28+
ruby_exe("").sub("+PRISM ", "").sub(/\+GC(\[\w+\]\s|\s)?/, "")[/\A.*/].should == RUBY_DESCRIPTION.sub("+PRISM ", "").sub(/\+GC(\[\w+\]\s|\s)?/, "")
2929
end
3030

3131
it "ignores whitespace around the option" do
3232
ENV["RUBYOPT"] = ' -v '
33-
ruby_exe("").sub("+PRISM ", "")[/\A.*/].should == RUBY_DESCRIPTION.sub("+PRISM ", "")
33+
ruby_exe("").sub("+PRISM ", "").sub(/\+GC(\[\w+\]\s|\s)?/, "")[/\A.*/].should == RUBY_DESCRIPTION.sub("+PRISM ", "").sub(/\+GC(\[\w+\]\s|\s)?/, "")
3434
end
3535
end
3636

spec/ruby/core/array/pack/shared/basic.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
# NOTE: Added this case just to not forget about the decision in the ticket
5858
it "raise ArgumentError when a directive is unknown" do
5959
# additional directive ('a') is required for the X directive
60-
-> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError)
61-
-> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError)
62-
-> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError)
60+
-> { [@obj, @obj].pack("a R" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive 'R'/)
61+
-> { [@obj, @obj].pack("a 0" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive '0'/)
62+
-> { [@obj, @obj].pack("a :" + pack_format) }.should raise_error(ArgumentError, /unknown pack directive ':'/)
6363
end
6464
end
6565

spec/ruby/core/basicobject/equal_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
it "is unaffected by overriding __id__" do
1212
o1 = mock("object")
1313
o2 = mock("object")
14-
def o1.__id__; 10; end
15-
def o2.__id__; 10; end
14+
suppress_warning {
15+
def o1.__id__; 10; end
16+
def o2.__id__; 10; end
17+
}
1618
o1.equal?(o2).should be_false
1719
end
1820

spec/ruby/core/dir/shared/glob.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
end
1313

1414
it "raises an Encoding::CompatibilityError if the argument encoding is not compatible with US-ASCII" do
15-
pattern = "file*".dup.force_encoding Encoding::UTF_16BE
15+
pattern = "files*".dup.force_encoding Encoding::UTF_16BE
1616
-> { Dir.send(@method, pattern) }.should raise_error(Encoding::CompatibilityError)
1717
end
1818

spec/ruby/core/encoding/compatible_spec.rb

Lines changed: 292 additions & 292 deletions
Large diffs are not rendered by default.

spec/ruby/core/exception/system_call_error_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ def initialize
5353
e.should be_an_instance_of(@example_errno_class)
5454
end
5555

56+
it "sets an error message corresponding to an appropriate Errno class" do
57+
e = SystemCallError.new(@example_errno)
58+
e.message.should == 'Invalid argument'
59+
end
60+
5661
it "accepts an optional custom message preceding the errno" do
5762
exc = SystemCallError.new("custom message", @example_errno)
5863
exc.should be_an_instance_of(@example_errno_class)
@@ -81,6 +86,35 @@ def initialize
8186
SystemCallError.new('foo', 2.9).should == SystemCallError.new('foo', 2)
8287
end
8388

89+
it "treats nil errno as unknown error value" do
90+
SystemCallError.new(nil).should be_an_instance_of(SystemCallError)
91+
end
92+
93+
it "treats nil custom message as if it is not passed at all" do
94+
exc = SystemCallError.new(nil, @example_errno)
95+
exc.message.should == 'Invalid argument'
96+
end
97+
98+
it "sets an 'unknown error' message when an unknown error number" do
99+
platform_is_not :windows do
100+
SystemCallError.new(-1).message.should =~ /Unknown error(:)? -1/
101+
end
102+
103+
platform_is :windows do
104+
SystemCallError.new(-1).message.should == "The operation completed successfully."
105+
end
106+
end
107+
108+
it "adds a custom error message to an 'unknown error' message when an unknown error number and a custom message specified" do
109+
platform_is_not :windows do
110+
SystemCallError.new("custom message", -1).message.should =~ /Unknown error(:)? -1 - custom message/
111+
end
112+
113+
platform_is :windows do
114+
SystemCallError.new("custom message", -1).message.should == "The operation completed successfully. - custom message"
115+
end
116+
end
117+
84118
it "converts to Integer if errno is a Complex convertible to Integer" do
85119
SystemCallError.new('foo', Complex(2.9, 0)).should == SystemCallError.new('foo', 2)
86120
end

spec/ruby/core/integer/shared/exponent.rb

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,18 @@
4848
(-1).send(@method, 4611686018427387905).should eql(-1)
4949
end
5050

51-
it "returns Float::INFINITY when the number is too big" do
52-
-> {
53-
2.send(@method, 427387904).should == Float::INFINITY
54-
}.should complain(/warning: in a\*\*b, b may be too big/)
51+
ruby_version_is ""..."3.4" do
52+
it "returns Float::INFINITY when the number is too big" do
53+
-> {
54+
2.send(@method, 427387904).should == Float::INFINITY
55+
}.should complain(/warning: in a\*\*b, b may be too big/)
56+
end
57+
end
58+
59+
ruby_version_is "3.4" do
60+
it "raises an ArgumentError when the number is too big" do
61+
-> { 100000000.send(@method, 1000000000) }.should raise_error(ArgumentError)
62+
end
5563
end
5664

5765
it "raises a ZeroDivisionError for 0 ** -1" do
@@ -108,13 +116,23 @@
108116
-> { @bignum.send(@method, :symbol) }.should raise_error(TypeError)
109117
end
110118

111-
it "switch to a Float when the values is too big" do
112-
flt = nil
113-
-> {
114-
flt = @bignum.send(@method, @bignum)
115-
}.should complain(/warning: in a\*\*b, b may be too big/)
116-
flt.should be_kind_of(Float)
117-
flt.infinite?.should == 1
119+
ruby_version_is ""..."3.4" do
120+
it "switch to a Float when the values is too big" do
121+
flt = nil
122+
-> {
123+
flt = @bignum.send(@method, @bignum)
124+
}.should complain(/warning: in a\*\*b, b may be too big/)
125+
flt.should be_kind_of(Float)
126+
flt.infinite?.should == 1
127+
end
128+
end
129+
130+
ruby_version_is "3.4" do
131+
it "does not switch to a Float when the values is too big" do
132+
-> {
133+
@bignum.send(@method, @bignum)
134+
}.should raise_error(ArgumentError)
135+
end
118136
end
119137

120138
it "returns a complex number when negative and raised to a fractional power" do

spec/ruby/core/io/pread_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
@file.pread(0, 4).should == ""
6060
end
6161

62+
it "returns a buffer for maxlen = 0 when buffer specified" do
63+
buffer = +"foo"
64+
@file.pread(0, 4, buffer).should.equal?(buffer)
65+
buffer.should == "foo"
66+
end
67+
6268
it "ignores the offset for maxlen = 0, even if it is out of file bounds" do
6369
@file.pread(0, 400).should == ""
6470
end

spec/ruby/core/io/set_encoding_by_bom_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@
6262
@io.rewind
6363
@io.set_encoding(Encoding::ASCII_8BIT)
6464

65-
File.binwrite(@name, "\xFE\xFFabc")
65+
File.binwrite(@name, "\xFE\xFFabcd")
6666

6767
@io.set_encoding_by_bom.should == Encoding::UTF_16BE
6868
@io.external_encoding.should == Encoding::UTF_16BE
69-
@io.read.b.should == "abc".b
69+
@io.read.b.should == "abcd".b
7070
end
7171

7272
it "returns the result encoding if found BOM UTF_32LE sequence" do
@@ -94,11 +94,11 @@
9494
@io.rewind
9595
@io.set_encoding(Encoding::ASCII_8BIT)
9696

97-
File.binwrite(@name, "\x00\x00\xFE\xFFabc")
97+
File.binwrite(@name, "\x00\x00\xFE\xFFabcd")
9898

9999
@io.set_encoding_by_bom.should == Encoding::UTF_32BE
100100
@io.external_encoding.should == Encoding::UTF_32BE
101-
@io.read.b.should == "abc".b
101+
@io.read.b.should == "abcd".b
102102
end
103103

104104
it "returns nil if io is empty" do

0 commit comments

Comments
 (0)