diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-21 13:48:57 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-21 13:48:57 +0000 |
commit | ecd5bbe82a925ad7154bc7a16b689b4ae383e44d (patch) | |
tree | a86835b350c0206542c6dc9188a8040c9bf32665 /test/strscan/test_stringscanner.rb | |
parent | 9662e3ded501f8df72e7ba80e6eb35ae86bbecc9 (diff) | |
download | ruby-ecd5bbe82a925ad7154bc7a16b689b4ae383e44d.tar.gz |
* ext/strscan/strscan.c (strscan_aref): support named captures.
patched by Konstantin Haase [ruby-core:54664] [Feature #8343]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/strscan/test_stringscanner.rb')
-rw-r--r-- | test/strscan/test_stringscanner.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb index 2c4cf90828..7f2e5c1ccd 100644 --- a/test/strscan/test_stringscanner.rb +++ b/test/strscan/test_stringscanner.rb @@ -457,6 +457,17 @@ class TestStringScanner < Test::Unit::TestCase assert_equal true, s[2].tainted? assert_equal true, s[3].tainted? assert_equal true, s[4].tainted? + + s = StringScanner.new("foo bar") + s.scan /(?<a>(\w+)) (?<b>(\w+))/ + assert_equal 'foo', s[1] + assert_equal 'bar', s[2] + assert_equal 'foo', s[:a] + assert_equal 'bar', s[:b] + assert_equal nil, s[:c] + assert_equal 'foo', s['a'] + assert_equal 'bar', s['b'] + assert_equal nil, s['c'] end def test_pre_match |