aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/optional
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2020-08-28 20:26:02 +0200
committerBenoit Daloze <eregontp@gmail.com>2020-08-28 20:26:02 +0200
commitb49307c701911a713cbdb48367833d3661a4880a (patch)
tree75674a3f22bee0b347b3efbbcc160bc7a637b8e3 /spec/ruby/optional
parent3dd63108b0e7551aba76eba85a459b58ec971ccb (diff)
downloadruby-b49307c701911a713cbdb48367833d3661a4880a.tar.gz
Update to ruby/spec@335eb9b
Diffstat (limited to 'spec/ruby/optional')
-rw-r--r--spec/ruby/optional/capi/ext/regexp_spec.c6
-rw-r--r--spec/ruby/optional/capi/regexp_spec.rb4
2 files changed, 10 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/ext/regexp_spec.c b/spec/ruby/optional/capi/ext/regexp_spec.c
index 58ab079eff..70780bae2a 100644
--- a/spec/ruby/optional/capi/ext/regexp_spec.c
+++ b/spec/ruby/optional/capi/ext/regexp_spec.c
@@ -35,6 +35,11 @@ VALUE regexp_spec_backref_get(VALUE self) {
return rb_backref_get();
}
+VALUE regexp_spec_reg_match_backref_get(VALUE self, VALUE re, VALUE str) {
+ rb_reg_match(re, str);
+ return rb_backref_get();
+}
+
VALUE regexp_spec_match(VALUE self, VALUE regexp, VALUE str) {
return rb_funcall(regexp, rb_intern("match"), 1, str);
}
@@ -46,6 +51,7 @@ void Init_regexp_spec(void) {
rb_define_method(cls, "a_re_1st_match", regexp_spec_reg_1st_match, 1);
rb_define_method(cls, "rb_reg_match", regexp_spec_reg_match, 2);
rb_define_method(cls, "rb_backref_get", regexp_spec_backref_get, 0);
+ rb_define_method(cls, "rb_reg_match_backref_get", regexp_spec_reg_match_backref_get, 2);
rb_define_method(cls, "rb_reg_options", regexp_spec_rb_reg_options, 1);
rb_define_method(cls, "rb_reg_regcomp", regexp_spec_rb_reg_regcomp, 1);
}
diff --git a/spec/ruby/optional/capi/regexp_spec.rb b/spec/ruby/optional/capi/regexp_spec.rb
index d99935da57..806157368d 100644
--- a/spec/ruby/optional/capi/regexp_spec.rb
+++ b/spec/ruby/optional/capi/regexp_spec.rb
@@ -75,5 +75,9 @@ describe "C-API Regexp function" do
md = /c/.match('ab')
@p.rb_backref_get.should == md
end
+
+ it "returns MatchData when used with rb_reg_match" do
+ @p.rb_reg_match_backref_get(/a/, 'ab')[0].should == 'a'
+ end
end
end