Skip to content

Update test_regexp.rb and test_marshal.rb from CRuby - #10127

Merged
headius merged 2 commits into
jruby:ruby-4.1from
zev:mri-sync-regexp-marshal
Dec 1, 2026
Merged

headius merged 2 commits into
jruby:ruby-4.1from
zev:mri-sync-regexp-marshal

Conversation

@zev

@zev zev commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Updates test/mri/ruby/test_regexp.rb and test_marshal.rb to current CRuby copies (Ruby 4.1.0-dev): test_regexp.rb from ruby/ruby@197b8f0103, test_marshal.rb from ruby/ruby@a37c2dbf1b. Both files are copied whole over the 4.0.9 copies from d7c208c, which have no JRuby edits.

The Regexp freeze PR (#10128) needs this: CRuby changed three assertions in ruby/ruby@cb03bf43eb to expect frozen Regexp instances.

The second commit moves test_marshal.rb to a37c2dbf1b for ruby/ruby@20937c9b8e, which adds test_uclass_regexp_with_non_regexp_class. That commit fixes a crash in CRuby's version of the Regexp freeze: Marshal.load accepted a non-Regexp user class around a Regexp. JRuby already raises ArgumentError there, before and after #10128. test_regexp.rb stays at 197b8f0103; it has 35 later CRuby commits, mostly Onigmo fixes, which belong in their own sync.

Excludes

Only additions; the existing excludes, including the ones added with the 4.0.9 sync, are unchanged. The new tests that fail on JRuby:

  • TestRegexp#test_dup and TestMarshal#test_regexp2: expect frozen Regexp instances. Freeze all instances of Regexp, except subclass instances #10128 removes these two.
  • TestRegexp:
    • test_extended_comment_compiled_again_for_string: an EMACS_MULE extended-mode comment gives 5 groups instead of 3. This passed on ruby-4.1 at e2ac87b and regressed since; not investigated yet.
    • test_index_with_assertion_before_leading_anychar_star, test_rindex_with_leading_anychar_star_multiline: String#index/rindex return nil.
    • test_s_timeout_corner_cases, test_timeout_corner_cases: no ArgumentError for out-of-range timeouts.
    • test_extended_comment_invalid_unicode_escape_with_multibyte_characters: SyntaxError.
    • test_once_implicit_match: needs investigation.
    • test_match_aref, test_matchdata_large_capture_groups_stack, test_regsub_no_memory_leak_many_captures: need RbConfig::LIMITS, RubyVM or assert_no_memory_leak.
  • TestMarshal: test_load_overread_string_body (same cause as the existing test_load_overread exclude), test_marshal_false_proc, test_modify_string_during_dump, test_uclass_module_not_relabeled, test_user_class_struct_size, test_continuation (needs callcc).
  • TestMarshalFreeze#test_uclass_fstring.

Several are real bugs worth separate fixes; I left them for follow-up PRs.

Testing

Both files, interpreter and forced JIT, on this branch merged with current ruby-4.1: 0 failures (test_regexp.rb 128 tests, test_marshal.rb 196 tests; the new test also passes on the ruby-4.1 base).

🤖 Generated with Claude Code

@zev

zev commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Review and merge order for the Regexp freeze work (Feature #8948):

  1. Check Regexp state before setting options in rb_reg_initialize #10126 (jruby-10.0): check the Regexp state before setting options in rb_reg_initialize. It's independent and can merge any time.
  2. Update test_regexp.rb and test_marshal.rb from CRuby #10127 (ruby-4.1): sync test_regexp.rb and test_marshal.rb from CRuby, with excludes. ← this PR
  3. Freeze all instances of Regexp, except subclass instances #10128 (ruby-4.1): freeze Regexp instances. It's stacked on Update test_regexp.rb and test_marshal.rb from CRuby #10127, so merge that first. It also carries the Check Regexp state before setting options in rb_reg_initialize #10126 commit, because the freeze depends on it.

Copied whole from ruby/ruby@197b8f0103 (Ruby 4.1.0-dev). The new
tests that fail on JRuby are excluded with the reason. test_dup and
test_regexp2 now expect frozen Regexp instances (Feature jruby#8948).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zev
zev force-pushed the mri-sync-regexp-marshal branch from 1975f66 to 3b2324c Compare November 24, 2026 03:36
@zev
zev marked this pull request as ready for review December 1, 2026 03:33
Picks up ruby/ruby@20937c9b8e, which adds
test_uclass_regexp_with_non_regexp_class: a TYPE_UCLASS record naming a
class that is not a Regexp subclass around a Regexp must raise
ArgumentError. JRuby already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@headius headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debating whether we should just tag off all of the remaining 4.1 failures with some text to indicate they are new 4.1 features and just let contributors remove the tags/excludes as they are fixed. Some excludes added here make me lean that way now.

Approved.

@headius
headius merged commit 0dfb433 into jruby:ruby-4.1 Dec 1, 2026
126 of 149 checks passed
@headius headius added this to the JRuby 10.2.0.0 milestone Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants