diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-17 17:10:01 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-17 17:10:01 +0000 |
commit | a14a58b959405ca4f7b8472f331a404269daeb2e (patch) | |
tree | 18efe622116c20aebc0ce93dccb270652b4941b0 /test | |
parent | 3d0850932ab8842845fb9279754e41acf4380e2f (diff) | |
download | ruby-a14a58b959405ca4f7b8472f331a404269daeb2e.tar.gz |
* re.c (match_values_at): MatchData#values_at supports named captures
[Feature #9179]
* re.c (namev_to_backref_number): separeted.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_regexp.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 1eb7e24b8c..aea2f2f6ea 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -383,6 +383,13 @@ class TestRegexp < Test::Unit::TestCase def test_match_values_at m = /(...)(...)(...)(...)?/.match("foobarbaz") assert_equal(["foo", "bar", "baz"], m.values_at(1, 2, 3)) + + m = /(?<a>\d+) *(?<op>[+\-*\/]) *(?<b>\d+)/.match("1 + 2") + assert_equal(["1", "2", "+"], m.values_at(:a, 'b', :op)) + idx = Object.new + def idx.to_int; 2; end + assert_equal(["+"], m.values_at(idx)) + assert_raise(TypeError){ m.values_at(nil) } end def test_match_string |