summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-17 17:10:01 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-17 17:10:01 +0000
commit92f8d74a3e9fe8095bc67b684ac5207cc7d9deaa (patch)
tree18efe622116c20aebc0ce93dccb270652b4941b0 /test
parent0f621628a9f8a3efec74fbee2c0266e8639f3664 (diff)
* 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.rb7
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