Repository navigation
String methods: advance MRI 4.0.6 conformance (index/rindex/sub/gsub/scan/casecmp/chomp/partition/tr/split/…) - #535
Merged
Merged
Conversation
…s args, offsets (MRI 4.0.6) index gains Regexp matching (sets $~), start-offset via #to_int, first-arg #to_str coercion and String-subclass unwrapping; rindex gains proper offset semantics, Regexp reverse search, #to_str coercion and subclass args. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rmance - sub/gsub: \+ backreference (last participating group), replacement takes precedence over a block, #to_str coercion of pattern and replacement, enumerator #size nil. - scan: sets $~ per match and to the last match after, result substrings inherit the receiver encoding, #to_str pattern coercion. - casecmp: ASCII-only fold then byte compare; casecmp? full Unicode fold; both coerce via #to_str, unwrap subclasses, and return nil on an unconvertible arg or incompatible encoding. - chomp/chomp!: honour $/ for the no-arg form, treat an explicit nil as no chomp, treat the "\n" separator as smart mode (\r\n/\n/\r), #to_str arg. - partition/rpartition: Regexp separators (setting $~), #to_str coercion, String-instance and same-encoding results. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- tr/tr_s/count/delete/squeeze: operate on whole code points (multibyte characters match as a unit, never partially) and coerce set args via #to_str; reversed ranges still raise ArgumentError. - split: awk mode yields one trailing empty field under a non-zero limit; a nil/absent pattern falls back to $; (String or Regexp). - replace: coerces the source via #to_str. - bytes/codepoints: block form yields each element and returns the receiver. - each_line: honours $/ for the no-arg form; its enumerator #size is nil. - next/next! are true aliases of succ/succ!. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
casecmp/casecmp? now raise TypeError (not nil) when the argument's #to_str yields a non-String, matching MRI; only a value with no #to_str compares as nil. Adds unit tests for the search/coerce edge branches. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Simplify chompSep's $/ handling and add unit tests covering the no-match Regexp paths of rindex/rpartition, gsub block-only, sub arity error, and subclass/String pattern coercion. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds unit tests for gsub!/sub! change, no-change nil, ArgumentError arity, and the no-replacement enumerator (size nil + materialization). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Exercises the in-place bang variants whose set-argument coercion was updated, so every String closure changed in this branch is covered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Sep 1, 2026
Locks in #535 (String methods: index/casecmp/chomp/gsub/scan/tr/... ~+110), #536 (IO/StringIO reader+writer), #538 (Array#[]= auto-grow + mutators), #539 (Range + Comparable), #540 (Struct + Data), #541 (Time). Measured 17983 passing on the pinned corpus, up from 17654. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances MRI-Ruby-4.0.6 conformance for the String-method (non-encoding) cluster in
core/string/*_spec.rb. All work is by whole-method behaviour verified byte-for-byte against MRI 4.0.6 (result, error class/message, and post-match$~/$1globals). Encoding negotiation (Encoding::CompatibilityError,force_encoding, transcoding) is intentionally left to the separate encoding effort.rubyspec deltas (pass count, per file)
Aggregate over
core/string/*_spec.rb: roughly +100 examples now passing, with theno implicit conversionTypeError errors across these methods largely eliminated.What changed
index/rindex: Regexp arguments (setting$~), start-offset via#to_int, first-argument#to_strcoercion, String-subclass unwrapping, and correct reverse-search/offset semantics.sub/gsub:\+backreference (last participating group); a replacement argument now takes precedence over a block;#to_strcoercion of pattern and replacement; enumerator#sizeisnil.scan: sets$~per match and to the last match afterwards; result substrings inherit the receiver's encoding;#to_strpattern coercion.casecmp/casecmp?: ASCII-only fold + byte compare vs. full Unicode fold respectively;#to_strcoercion, subclass unwrapping,nilon unconvertible/incompatible, TypeError when#to_strreturns a non-String.chomp/chomp!: honour$/for the no-arg form, treat explicitnilas no-op, treat the"\n"separator as smart mode.partition/rpartition: Regexp separators (setting$~),#to_strcoercion, plain-String same-encoding results.tr/tr_s/count/delete/squeeze: operate on whole code points (no partial multibyte matches) and coerce set args via#to_str.split: awk mode yields one trailing empty field under a non-zero limit; a nil/absent pattern falls back to$;(String or Regexp).replace#to_str;bytes/codepointsblock forms;each_line$/+ nil enumerator size;next/next!true aliases ofsucc/succ!.Tests
New
internal/vm/string_method_residuals_test.gocovers every new branch.go test ./internal/vm/andgo test ./...green;GOOS=js GOARCH=wasmbuild OK;gofmtclean.🤖 Generated with Claude Code