diff options
Diffstat (limited to 'test/strscan')
-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 |