summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringscanner/scan_full_spec.rb
diff options
context:
space:
mode:
authorAndrew Konchin <[email protected]>2025-03-26 19:56:40 +0200
committerBenoit Daloze <[email protected]>2025-03-27 11:09:24 +0100
commitbac22c985ecc7e4309b5b5e5ae1074c81319e889 (patch)
tree5c164d3ed99240737205068f612d47496487758e /spec/ruby/library/stringscanner/scan_full_spec.rb
parent53a930f1570c81d2f7829f932e8d7ad67e8462b8 (diff)
Update to ruby/spec@5e579e2
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12984
Diffstat (limited to 'spec/ruby/library/stringscanner/scan_full_spec.rb')
-rw-r--r--spec/ruby/library/stringscanner/scan_full_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/library/stringscanner/scan_full_spec.rb b/spec/ruby/library/stringscanner/scan_full_spec.rb
index ed34d7d3f6..967313f5ca 100644
--- a/spec/ruby/library/stringscanner/scan_full_spec.rb
+++ b/spec/ruby/library/stringscanner/scan_full_spec.rb
@@ -27,4 +27,18 @@ describe "StringScanner#scan_full" do
@s.scan_full(/This/, true, true).should == "This"
@s.pos.should == 4
end
+
+ describe "#[] successive call with a capture group name" do
+ it "returns matched substring when matching succeeded" do
+ @s.scan_full(/(?<a>This)/, false, false)
+ @s.should.matched?
+ @s[:a].should == "This"
+ end
+
+ it "returns nil when matching failed" do
+ @s.scan_full(/(?<a>2008)/, false, false)
+ @s.should_not.matched?
+ @s[:a].should be_nil
+ end
+ end
end