Skip to content
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

Regexp#match{?} with nil raises TypeError as String, Symbol #1506

Merged
merged 8 commits into from
Oct 17, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions spec/ruby/core/regexp/match_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,6 @@
end
end

it "resets $~ if passed nil" do
# set $~
/./.match("a")
$~.should be_kind_of(MatchData)

/1/.match(nil)
$~.should be_nil
end
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to add a ruby_version_is ""..."2.6" guard instead of removing, since the behavior continues to apply to older versions.
Could you also add specs for the new behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

Addresses in 1041650 ~


it "raises TypeError when the given argument cannot be coarce to String" do
f = 1
lambda { /foo/.match(f)[0] }.should raise_error(TypeError)
Expand Down Expand Up @@ -133,10 +124,6 @@
/str/i.match?('string', 0).should be_true
/str/i.match?('string', 1).should be_false
end

it "returns false when given nil" do
/./.match?(nil).should be_false
end
end
end

Expand Down