diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2019-12-04 01:26:29 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2019-12-04 06:40:54 +0900 |
commit | 8852fa876039ed177fd5e867f36177d8a9ff411c (patch) | |
tree | 56dd2c368bfe7cc694bf333c3ef987e2fee1b727 /spec/ruby | |
parent | 08074eb71229b4c9f669f7bfb215bbb43525bfc0 (diff) | |
download | ruby-8852fa876039ed177fd5e867f36177d8a9ff411c.tar.gz |
Revert "Regexp#match{?} with nil raises TypeError as String, Symbol (#1506)"
This reverts commit 2a22a6b2d8465934e75520a7fdcf522d50890caf.
Revert [Feature #13083]
Diffstat (limited to 'spec/ruby')
-rw-r--r-- | spec/ruby/core/regexp/match_spec.rb | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/spec/ruby/core/regexp/match_spec.rb b/spec/ruby/core/regexp/match_spec.rb index 89cb3be4f6..80dbfb4c10 100644 --- a/spec/ruby/core/regexp/match_spec.rb +++ b/spec/ruby/core/regexp/match_spec.rb @@ -5,15 +5,15 @@ describe :regexp_match, shared: true do it "returns nil if there is no match" do /xyz/.send(@method,"abxyc").should be_nil end + + it "returns nil if the object is nil" do + /\w+/.send(@method, nil).should be_nil + end end describe "Regexp#=~" do it_behaves_like :regexp_match, :=~ - it "returns nil if the object is nil" do - (/\w+/ =~ nil).should be_nil - end - it "returns the index of the first character of the matching region" do (/(.)(.)(.)/ =~ "abc").should == 0 end @@ -91,21 +91,13 @@ describe "Regexp#match" do end end - ruby_version_is ""..."2.7" do - it "resets $~ if passed nil" do - # set $~ - /./.match("a") - $~.should be_kind_of(MatchData) - - /1/.match(nil) - $~.should be_nil - end - end + it "resets $~ if passed nil" do + # set $~ + /./.match("a") + $~.should be_kind_of(MatchData) - ruby_version_is "2.7" do - it "raises TypeError when the given argument is nil" do - -> { /foo/.match(nil) }.should raise_error(TypeError) - end + /1/.match(nil) + $~.should be_nil end it "raises TypeError when the given argument cannot be coerced to String" do @@ -141,16 +133,8 @@ describe "Regexp#match?" do /str/i.match?('string', 1).should be_false end - ruby_version_is ""..."2.7" do - it "returns false when given nil" do - /./.match?(nil).should be_false - end - end - - ruby_version_is "2.7" do - it "raises TypeError when given nil" do - -> { /./.match?(nil) }.should raise_error(TypeError) - end + it "returns false when given nil" do + /./.match?(nil).should be_false end end |