mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
a039dc018c
commit
d5f0d338c7
Notes:
git
2020-12-16 02:55:10 +09:00
5 changed files with 99 additions and 26 deletions
|
@ -40,15 +40,25 @@ describe "Enumerable#grep" do
|
|||
$~.should == nil
|
||||
end
|
||||
|
||||
it "sets $~ to the last match when given no block" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].grep(/b/).should == ["abc"]
|
||||
ruby_version_is ""..."3.0.0" do
|
||||
it "sets $~ to the last match when given no block" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].grep(/b/).should == ["abc"]
|
||||
|
||||
# Set by the failed match of "def"
|
||||
$~.should == nil
|
||||
# Set by the failed match of "def"
|
||||
$~.should == nil
|
||||
|
||||
["abc", "def"].grep(/e/)
|
||||
$&.should == "e"
|
||||
["abc", "def"].grep(/e/)
|
||||
$&.should == "e"
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "3.0.0" do
|
||||
it "does not set $~ when given no block" do
|
||||
"z" =~ /z/ # Reset $~
|
||||
["abc", "def"].grep(/b/).should == ["abc"]
|
||||
$&.should == "z"
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a block" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue