8000 [Feature #20187] Skip examples for bundled gems at Ruby 3.4 by hsbt · Pull Request #9960 · ruby/ruby · GitHub
[go: up one dir, main page]

Skip to content

[Feature #20187] Skip examples for bundled gems at Ruby 3.4 #9960

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

Closed
wants to merge 9 commits into from
Closed
3 changes: 3 additions & 0 deletions spec/default.mspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ if (opt = ENV["RUBYOPT"]) and (opt = opt.dup).sub!(/(?:\A|\s)-w(?=\z|\s)/, '')
ENV["RUBYOPT"] = opt
end

# Disable to run for bundled gems
ENV["GEM_SKIP"] = ENV["GEM_HOME"] = ENV["GEM_PATH"] = "".freeze

# Enable leakcheckers by ruby/mspec
ENV["CHECK_LEAKS"] ||= "true"

Expand Down
157 changes: 80 additions & 77 deletions spec/ruby/core/integer/coerce_spec.rb
Original file line number Diff line number Diff line change
@@ -1,104 +1,107 @@
require_relative '../../spec_helper'

require 'bigdecimal'

describe "Integer#coerce" do
context "fixnum" do
describe "when given a Fixnum" do
it "returns an array containing two Fixnums" do
1.coerce(2).should == [2, 1]
1.coerce(2).map { |i| i.class }.should == [Integer, Integer]
end
end
ruby_version_is ""..."3.4" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This disables all Integer#coerce specs, it's not OK.
Same for Rational#coerce specs below.


describe "when given a String" do
it "raises an ArgumentError when trying to coerce with a non-number String" do
-> { 1.coerce(":)") }.should raise_error(ArgumentError)
require 'bigdecimal'

describe "Integer#coerce" do
context "fixnum" do
describe "when given a Fixnum" do
it "returns an array containing two Fixnums" do
1.coerce(2).should == [2, 1]
1.coerce(2).map { |i| i.class }.should == [Integer, Integer]
end
end

it "returns an array containing two Floats" do
1.coerce("2").should == [2.0, 1.0]
1.coerce("-2").should == [-2.0, 1.0]
describe "when given a String" do
it "raises an ArgumentError when trying to coerce with a non-number String" do
-> { 1.coerce(":)") }.should raise_error(ArgumentError)
end

it "returns an array containing two Floats" do
1.coerce("2").should == [2.0, 1.0]
1.coerce("-2").should == [-2.0, 1.0]
end
end
end

it "raises a TypeError when trying to coerce with nil" do
-> { 1.coerce(nil) }.should raise_error(TypeError)
end
it "raises a TypeError when trying to coerce with nil" do
-> { 1.coerce(nil) }.should raise_error(TypeError)
end

it "tries to convert the given Object into a Float by using #to_f" do
(obj = mock('1.0')).should_receive(:to_f).and_return(1.0)
2.coerce(obj).should == [1.0, 2.0]
it "tries to convert the given Object into a Float by using #to_f" do
(obj = mock('1.0')).should_receive(:to_f).and_return(1.0)
2.coerce(obj).should == [1.0, 2.0]

(obj = mock('0')).should_receive(:to_f).and_return('0')
-> { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError)
end
(obj = mock('0')).should_receive(:to_f).and_return('0')
-> { 2.coerce(obj).should == [1.0, 2.0] }.should raise_error(TypeError)
end

it "raises a TypeError when given an Object that does not respond to #to_f" do
-> { 1.coerce(mock('x')) }.should raise_error(TypeError)
-> { 1.coerce(1..4) }.should raise_error(TypeError)
-> { 1.coerce(:test) }.should raise_error(TypeError)
it "raises a TypeError when given an Object that does not respond to #to_f" do
-> { 1.coerce(mock('x')) }.should raise_error(TypeError)
-> { 1.coerce(1..4) }.should raise_error(TypeError)
-> { 1.coerce(:test) }.should raise_error(TypeError)
end
end
end

context "bignum" do
it "coerces other to a Bignum and returns [other, self] when passed a Fixnum" do
a = bignum_value
ary = a.coerce(2)
context "bignum" do
it "coerces other to a Bignum and returns [other, self] when passed a Fixnum" do
a = bignum_value
ary = a.coerce(2)

ary[0].should be_kind_of(Integer)
ary[1].should be_kind_of(Integer)
ary.should == [2, a]
end
ary[0].should be_kind_of(Integer)
ary[1].should be_kind_of(Integer)
ary.should == [2, a]
end

it "returns [other, self] when passed a Bignum" do
a = bignum_value
b = bignum_value
ary = a.coerce(b)
it "returns [other, self] when passed a Bignum" do
a = bignum_value
b = bignum_value
ary = a.coerce(b)

ary[0].should be_kind_of(Integer)
ary[1].should be_kind_of(Integer)
ary.should == [b, a]
end
ary[0].should be_kind_of(Integer)
ary[1].should be_kind_of(Integer)
ary.should == [b, a]
end

it "raises a TypeError when not passed a Fixnum or Bignum" do
a = bignum_value
it "raises a TypeError when not passed a Fixnum or Bignum" do
a = bignum_value

-> { a.coerce(nil) }.should raise_error(TypeError)
-> { a.coerce(mock('str')) }.should raise_error(TypeError)
-> { a.coerce(1..4) }.should raise_error(TypeError)
-> { a.coerce(:test) }.should raise_error(TypeError)
end
-> { a.coerce(nil) }.should raise_error(TypeError)
-> { a.coerce(mock('str')) }.should raise_error(TypeError)
-> { a.coerce(1..4) }.should raise_error(TypeError)
-> { a.coerce(:test) }.should raise_error(TypeError)
end

it "coerces both values to Floats and returns [other, self] when passed a Float" do
a = bignum_value
a.coerce(1.2).should == [1.2, a.to_f]
end
it "coerces both values to Floats and returns [other, self] when passed a Float" do
a = bignum_value
a.coerce(1.2).should == [1.2, a.to_f]
end

it "coerces both values to Floats and returns [other, self] when passed a String" do
a = bignum_value
a.coerce("123").should == [123.0, a.to_f]
end
it "coerces both values to Floats and returns [other, self] when passed a String" do
a = bignum_value
a.coerce("123").should == [123.0, a.to_f]
end

it "calls #to_f to coerce other to a Float" do
b = mock("bignum value")
b.should_receive(:to_f).and_return(1.2)
it "calls #to_f to coerce other to a Float" do
b = mock("bignum value")
b.should_receive(:to_f).and_return(1.2)

a = bignum_value
ary = a.coerce(b)
a = bignum_value
ary = a.coerce(b)

ary.should == [1.2, a.to_f]
ary.should == [1.2, a.to_f]
end
end
end

context "bigdecimal" do
it "produces Floats" do
x, y = 3.coerce(BigDecimal("3.4"))
x.class.should == Float
x.should == 3.4
y.class.should == Float
y.should == 3.0
context "bigdecimal" do
it "produces Floats" do
x, y = 3.coerce(BigDecimal("3.4"))
x.class.should == Float
x.should == 3.4
y.class.should == Float
y.should == 3.0
end
end
end

end
end
9 changes: 6 additions & 3 deletions spec/ruby/core/rational/coerce_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
require_relative "../../spec_helper"
require_relative '../../shared/rational/coerce'

describe "Rational#coerce" do
it_behaves_like :rational_coerce, :coerce
ruby_version_is ""..."3.4" do
require_relative '../../shared/rational/coerce'

describe "Rational#coerce" do
it_behaves_like :rational_coerce, :coerce
end
end
10 changes: 6 additions & 4 deletions spec/ruby/core/time/at_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
t2.nsec.should == t.nsec
end

describe "passed BigDecimal" do
it "doesn't round input value" do
require 'bigdecimal'
Time.at(BigDecimal('1.1')).to_f.should == 1.1
ruby_version_is ""..."3.4" do
describe "passed BigDecimal" do
it "doesn't round input value" do
require 'bigdecimal'
Time.at(BigDecimal('1.1')).to_f.should == 1.1
end
end
end

Expand Down
47 changes: 25 additions & 22 deletions spec/ruby/library/abbrev/abbrev_spec.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
require_relative '../../spec_helper'
require 'abbrev'

#test both Abbrev.abbrev and Array#abbrev in
#the same manner, as they're more or less aliases
#of one another
ruby_version_is ""..."3.4" do
require 'abbrev'

[["Abbrev.abbrev", -> a { Abbrev.abbrev(a)}],
["Array#abbrev", -> a { a.abbrev}]
].each do |(name, func)|
#test both Abbrev.abbrev and Array#abbrev in
#the same manner, as they're more or less aliases
#of one another

describe name do
it "returns a hash of all unambiguous abbreviations of the array of strings passed in" do
func.call(['ruby', 'rules']).should == {"rub" => "ruby",
"ruby" => "ruby",
"rul" => "rules",
"rule" => "rules",
"rules" => "rules"}
[["Abbrev.abbrev", -> a { Abbrev.abbrev(a)}],
["Array#abbrev", -> a { a.abbrev}]
].each do |(name, func)|

func.call(["car", "cone"]).should == {"ca" => "car",
"car" => "car",
"co" => "cone",
"con" => "cone",
"cone" => "cone"}
end
describe name do
it "returns a hash of all unambiguous abbreviations of the array of strings passed in" do
func.call(['ruby', 'rules']).should == {"rub" => "ruby",
"ruby" => "ruby",
"rul" => "rules",
"rule" => "rules",
"rules" => "rules"}

func.call(["car", "cone"]).should == {"ca" => "car",
"car" => "car",
"co" => "cone",
"con" => "cone",
"cone" => "cone"}
end

it "returns an empty hash when called on an empty array" do
func.call([]).should == {}
it "returns an empty hash when called on an empty array" do
func.call([]).should == {}
end
end
end
end
41 changes: 22 additions & 19 deletions spec/ruby/library/base64/decode64_spec.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
require_relative '../../spec_helper'

require 'base64'
ruby_version_is ""..."3.4" do

describe "Base64#decode64" do
it "returns the Base64-decoded version of the given string" do
Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n").should == "Send reinforcements"
end
require 'base64'

it "returns the Base64-decoded version of the given shared string" do
Base64.decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==\n".split(" ").last).should == "Send reinforcements"
end
describe "Base64#decode64" do
it "returns the Base64-decoded version of the given string" do
Base64.decode64("U2VuZCByZWluZm9yY2VtZW50cw==\n").should == "Send reinforcements"
end

it "returns the Base64-decoded version of the given string with wrong padding" do
Base64.decode64("XU2VuZCByZWluZm9yY2VtZW50cw===").should == "]M\x95\xB9\x90\x81\xC9\x95\xA5\xB9\x99\xBD\xC9\x8D\x95\xB5\x95\xB9\xD1\xCC".b
end
it "returns the Base64-decoded version of the given shared string" do
Base64.decode64("base64: U2VuZCByZWluZm9yY2VtZW50cw==\n".split(" ").last).should == "Send reinforcements"
end

it "returns the Base64-decoded version of the given string that contains an invalid character" do
Base64.decode64("%3D").should == "\xDC".b
end
it "returns the Base64-decoded version of the given string with wrong padding" do
Base64.decode64("XU2VuZCByZWluZm9yY2VtZW50cw===").should == "]M\x95\xB9\x90\x81\xC9\x95\xA5\xB9\x99\xBD\xC9\x8D\x95\xB5\x95\xB9\xD1\xCC".b
end

it "returns a binary encoded string" do
Base64.decode64("SEk=").encoding.should == Encoding::BINARY
end
it "returns the Base64-decoded version of the given string that contains an invalid character" do
Base64.decode64("%3D").should == "\xDC".b
end

it "returns a binary encoded string" do
Base64.decode64("SEk=").encoding.should == Encoding::BINARY
end

it "decodes without padding suffix ==" do
Base64.decode64("eyJrZXkiOnsibiI6InR0dCJ9fQ").should == "{\"key\":{\"n\":\"ttt\"}}"
it "decodes without padding suffix ==" do
Base64.decode64("eyJrZXkiOnsibiI6InR0dCJ9fQ").should == "{\"key\":{\"n\":\"ttt\"}}"
end
end
end
33 changes: 18 additions & 15 deletions spec/ruby/library/base64/encode64_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
require_relative '../../spec_helper'

require 'base64'
ruby_version_is ""..."3.4" do

describe "Base64#encode64" do
it "returns the Base64-encoded version of the given string" do
Base64.encode64("Now is the time for all good coders\nto learn Ruby").should ==
"Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nUnVieQ==\n"
end
require 'base64'

it "returns the Base64-encoded version of the given string" do
Base64.encode64('Send reinforcements').should == "U2VuZCByZWluZm9yY2VtZW50cw==\n"
end
describe "Base64#encode64" do
it "returns the Base64-encoded version of the given string" do
Base64.encode64("Now is the time for all good coders\nto learn Ruby").should ==
"Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g\nUnVieQ==\n"
end

it "returns the Base64-encoded version of the given shared string" do
Base64.encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
"dG8gbGVhcm4gUnVieQ==\n"
end
it "returns the Base64-encoded version of the given string" do
Base64.encode64('Send reinforcements').should == "U2VuZCByZWluZm9yY2VtZW50cw==\n"
end

it "returns the Base64-encoded version of the given shared string" do
Base64.encode64("Now is the time for all good coders\nto learn Ruby".split("\n").last).should ==
"dG8gbGVhcm4gUnVieQ==\n"
end

it "returns a US_ASCII encoded string" do
Base64.encode64("HI").encoding.should == Encoding::US_ASCII
it "returns a US_ASCII encoded string" do
Base64.encode64("HI").encoding.should == Encoding::US_ASCII
end
end
end
Loading
0