Skip to content

Commit

Permalink
Fix building native extension for cext-ruby/string/test_capacity.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
andrykonchin committed Nov 12, 2024
1 parent 73279f9 commit 9c850e4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/mri/tests/cext-c/string/fstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ bug_s_fstring(VALUE self, VALUE str)
return rb_fstring(str);
}

#ifndef TRUFFLERUBY
VALUE
bug_s_fstring_fake_str(VALUE self)
{
static const char literal[] = "abcdefghijklmnopqrstuvwxyz";
struct RString fake_str;
return rb_fstring(rb_setup_fake_str(&fake_str, literal, sizeof(literal) - 1, 0));
}
#endif

VALUE
bug_s_rb_enc_interned_str(VALUE self, VALUE encoding)
Expand All @@ -34,7 +36,11 @@ void
Init_string_fstring(VALUE klass)
{
rb_define_singleton_method(klass, "fstring", bug_s_fstring, 1);
// Skip fstring_fake_str because it's a dependency of cext-ruby/string/test_fstring.rb that's excluded
// and building fails because of not declared/implemented rb_setup_fake_str.
#ifndef TRUFFLERUBY
rb_define_singleton_method(klass, "fstring_fake_str", bug_s_fstring_fake_str, 0);
#endif
rb_define_singleton_method(klass, "rb_enc_interned_str", bug_s_rb_enc_interned_str, 1);
rb_define_singleton_method(klass, "rb_enc_str_new", bug_s_rb_enc_str_new, 1);
}

0 comments on commit 9c850e4

Please sign in to comment.