1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Revert nil error and adding deprecation message

This commit is contained in:
Kenichi Kamiya 2019-11-02 00:54:36 +09:00 committed by Benoit Daloze
parent 772b0613c5
commit 452bee3ee8
Notes: git 2019-11-03 19:03:36 +09:00
3 changed files with 25 additions and 7 deletions

View file

@ -87,7 +87,7 @@ describe "Regexp#match" do
end
end
ruby_version_is ""..."2.7" do
ruby_version_is ""..."3.0" do
it "resets $~ if passed nil" do
# set $~
/./.match("a")
@ -98,7 +98,13 @@ describe "Regexp#match" do
end
end
ruby_version_is "2.7" do
ruby_version_is "2.7"..."3.0" do
it "warns the deprecation when the given argument is nil" do
-> { /foo/.match(nil) }.should complain(/given argument is nil/)
end
end
ruby_version_is "3.0" do
it "raises TypeError when the given argument is nil" do
-> { /foo/.match(nil) }.should raise_error(TypeError)
end
@ -137,13 +143,19 @@ describe "Regexp#match?" do
/str/i.match?('string', 1).should be_false
end
ruby_version_is ""..."2.7" do
ruby_version_is ""..."3.0" do
it "returns false when given nil" do
/./.match?(nil).should be_false
end
end
ruby_version_is "2.7" do
ruby_version_is "2.7"..."3.0" do
it "warns the deprecation" do
-> { /./.match?(nil) }.should complain(/given argument is nil/)
end
end
ruby_version_is "3.0" do
it "raises TypeError when given nil" do
-> { /./.match?(nil) }.should raise_error(TypeError)
end