Skip to content

Commit

Permalink
Update to ruby/spec@bfd843a
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Sep 30, 2020
1 parent bbecf1e commit 65e8a29
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 61 deletions.
16 changes: 7 additions & 9 deletions spec/ruby/core/data/constants_spec.rb
@@ -1,15 +1,13 @@
require_relative '../../spec_helper'

ruby_version_is ""..."3.0" do
describe "Data" do
it "is a subclass of Object" do
suppress_warning do
Data.superclass.should == Object
end
describe "Data" do
it "is a subclass of Object" do
suppress_warning do
Data.superclass.should == Object
end
end

it "is deprecated" do
-> { Data }.should complain(/constant ::Data is deprecated/)
end
it "is deprecated" do
-> { Data }.should complain(/constant ::Data is deprecated/)
end
end
14 changes: 6 additions & 8 deletions spec/ruby/core/env/index_spec.rb
@@ -1,14 +1,12 @@
require_relative '../../spec_helper'
require_relative 'shared/key'

ruby_version_is ""..."3.0" do
describe "ENV.index" do
it_behaves_like :env_key, :index
describe "ENV.index" do
it_behaves_like :env_key, :index

it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
end
it "warns about deprecation" do
-> do
ENV.index("foo")
end.should complain(/warning: ENV.index is deprecated; use ENV.key/)
end
end
32 changes: 15 additions & 17 deletions spec/ruby/core/integer/constants_spec.rb
@@ -1,27 +1,25 @@
require_relative '../../spec_helper'

ruby_version_is ""..."3.0" do
describe "Fixnum" do
it "is unified into Integer" do
suppress_warning do
Fixnum.should equal(Integer)
end
describe "Fixnum" do
it "is unified into Integer" do
suppress_warning do
Fixnum.should equal(Integer)
end
end

it "is deprecated" do
-> { Fixnum }.should complain(/constant ::Fixnum is deprecated/)
end
it "is deprecated" do
-> { Fixnum }.should complain(/constant ::Fixnum is deprecated/)
end
end

describe "Bignum" do
it "is unified into Integer" do
suppress_warning do
Bignum.should equal(Integer)
end
describe "Bignum" do
it "is unified into Integer" do
suppress_warning do
Bignum.should equal(Integer)
end
end

it "is deprecated" do
-> { Bignum }.should complain(/constant ::Bignum is deprecated/)
end
it "is deprecated" do
-> { Bignum }.should complain(/constant ::Bignum is deprecated/)
end
end
2 changes: 1 addition & 1 deletion spec/ruby/core/kernel/match_spec.rb
Expand Up @@ -14,7 +14,7 @@
end
end

ruby_version_is "2.6"..."3.0" do
ruby_version_is "2.6" do
it "is deprecated" do
-> do
Object.new =~ /regexp/
Expand Down
18 changes: 10 additions & 8 deletions spec/ruby/core/marshal/dump_spec.rb
Expand Up @@ -411,15 +411,17 @@ def obj.foo; end
load.should == (1...2)
end

it "dumps a Range with extra instance variables" do
range = (1...3)
range.instance_variable_set :@foo, 42
dump = Marshal.dump(range)
load = Marshal.load(dump)
load.should == range
load.instance_variable_get(:@foo).should == 42
ruby_version_is ""..."3.0" do
it "dumps a Range with extra instance variables" do
range = (1...3)
range.instance_variable_set :@foo, 42
dump = Marshal.dump(range)
load = Marshal.load(dump)
load.should == range
load.instance_variable_get(:@foo).should == 42
end
end
end unless (1...3).frozen? # Ruby 3.0 -
end

describe "with a Time" do
before :each do
Expand Down
10 changes: 0 additions & 10 deletions spec/ruby/core/module/deprecate_constant_spec.rb
Expand Up @@ -10,16 +10,6 @@
@module.private_constant :PRIVATE
@module.deprecate_constant :PRIVATE
@pattern = /deprecated/
if Warning.respond_to?(:[])
@deprecated = Warning[:deprecated]
Warning[:deprecated] = true
end
end

after :each do
if Warning.respond_to?(:[])
Warning[:deprecated] = @deprecated
end
end

describe "when accessing the deprecated module" do
Expand Down
14 changes: 9 additions & 5 deletions spec/ruby/core/range/initialize_spec.rb
Expand Up @@ -27,16 +27,20 @@
-> { @range.send(:initialize, 1, 3, 5, 7, 9) }.should raise_error(ArgumentError)
end

it "raises a NameError if called on an already initialized Range" do
if (0..1).frozen? # Ruby 3.0-
-> { (0..1).send(:initialize, 1, 3) }.should raise_error(FrozenError)
-> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(FrozenError)
else
ruby_version_is ""..."3.0" do
it "raises a NameError if called on an already initialized Range" do
-> { (0..1).send(:initialize, 1, 3) }.should raise_error(NameError)
-> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(NameError)
end
end

ruby_version_is "3.0" do
it "raises a FrozenError if called on an already initialized Range" do
-> { (0..1).send(:initialize, 1, 3) }.should raise_error(FrozenError)
-> { (0..1).send(:initialize, 1, 3, true) }.should raise_error(FrozenError)
end
end

it "raises an ArgumentError if arguments don't respond to <=>" do
o1 = Object.new
o2 = Object.new
Expand Down
4 changes: 2 additions & 2 deletions spec/ruby/language/predefined_spec.rb
Expand Up @@ -654,7 +654,7 @@ def foo
-> { $, = Object.new }.should raise_error(TypeError)
end

ruby_version_is "2.7"..."3.0" do
ruby_version_is "2.7" do
it "warns if assigned non-nil" do
-> { $, = "_" }.should complain(/warning: `\$,' is deprecated/)
end
Expand Down Expand Up @@ -693,7 +693,7 @@ def foo
$; = nil
end

ruby_version_is "2.7"..."3.0" do
ruby_version_is "2.7" do
it "warns if assigned non-nil" do
-> { $; = "_" }.should complain(/warning: `\$;' is deprecated/)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/ruby/library/net/http/HTTPServerException_spec.rb
Expand Up @@ -13,7 +13,7 @@
end
end

ruby_version_is "2.6"..."3.0" do
ruby_version_is "2.6" do
describe "Net::HTTPServerException" do
it "is a subclass of Net::ProtoServerError and is warned as deprecated" do
-> { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
Expand Down

0 comments on commit 65e8a29

Please sign in to comment.