aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/core/symbol/match_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-03-28 00:22:51 +0100
committerBenoit Daloze <eregontp@gmail.com>2020-03-28 00:22:51 +0100
commitf234d51eaba861edea925eabb564a0bee41b96a0 (patch)
tree3334f36a91fe81ec704f2980ab169231f52c41d0 /spec/ruby/core/symbol/match_spec.rb
parent296f68816cf575b3ff920f92aec8a4109a7d81d4 (diff)
downloadruby-f234d51eaba861edea925eabb564a0bee41b96a0.tar.gz
Update to ruby/spec@ec84479
Diffstat (limited to 'spec/ruby/core/symbol/match_spec.rb')
-rw-r--r--spec/ruby/core/symbol/match_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/symbol/match_spec.rb b/spec/ruby/core/symbol/match_spec.rb
index d37155537b..41e058f977 100644
--- a/spec/ruby/core/symbol/match_spec.rb
+++ b/spec/ruby/core/symbol/match_spec.rb
@@ -34,6 +34,23 @@ describe "Symbol#match" do
:a.match(/(.)/)[0].should == 'a'
$1.should == "a"
end
+
+ describe "when passed a block" do
+ it "yields the MatchData" do
+ :abc.match(/./) {|m| ScratchPad.record m }
+ ScratchPad.recorded.should be_kind_of(MatchData)
+ end
+
+ it "returns the block result" do
+ :abc.match(/./) { :result }.should == :result
+ end
+
+ it "does not yield if there is no match" do
+ ScratchPad.record []
+ :b.match(/a/) {|m| ScratchPad << m }
+ ScratchPad.recorded.should == []
+ end
+ end
end
describe "Symbol#match?" do