зеркало из https://github.com/github/ruby.git
[ruby/strscan] Sync missed commit
Syncs commit ruby/strscan@76b377a5d8.
This commit is contained in:
Родитель
ccca097cb5
Коммит
e27eab2f85
|
@ -1502,7 +1502,9 @@ strscan_named_captures(VALUE self)
|
|||
named_captures_data data;
|
||||
data.self = self;
|
||||
data.captures = rb_hash_new();
|
||||
if (!RB_NIL_P(p->regex)) {
|
||||
onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data);
|
||||
}
|
||||
|
||||
return data.captures;
|
||||
}
|
||||
|
|
|
@ -775,6 +775,7 @@ module StringScannerTests
|
|||
def test_named_captures
|
||||
omit("not implemented on TruffleRuby") if ["truffleruby"].include?(RUBY_ENGINE)
|
||||
scan = StringScanner.new("foobarbaz")
|
||||
assert_equal({}, scan.named_captures)
|
||||
assert_equal(9, scan.match?(/(?<f>foo)(?<r>bar)(?<z>baz)/))
|
||||
assert_equal({"f" => "foo", "r" => "bar", "z" => "baz"}, scan.named_captures)
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче