test: ask what case conversion answers where it follows ASCII - #7223
Conversation
Where a build converts case by ASCII, whether by defining `MRB_USE_ASCII_CASE`
or by reading its strings as bytes, nothing asked what the conversion answers.
Every assertion that would show the narrowing is gated off rather than
mirrored: the blocks in core are not defined, those in mruby-string-ext report
as Skip, and the line in mruby-encoding is dropped. The conversion was held to
"nothing raised" rather than to an answer:
```ruby
# where case follows ASCII
"Ä".downcase #=> "Ä", and "ä" where it follows Unicode
"ä".upcase #=> "ä"
"ä".casecmp?("Ä") #=> false
```
Gate the mirrors the other way. One addition then covers both configurations
that convert case by ASCII, and each sits beside the Unicode block it answers.
Core holds `String#downcase`, `#upcase` and `#capitalize`, and asks for the
bytes of a run that spells no character handed back, the refusal such a run
draws elsewhere belonging to the walk over characters. mruby-string-ext holds
`String#swapcase` and `#casecmp?`. mruby-encoding asks what the bytes of `"Ä"`
read as UTF-8 answer, which is what the same bytes read as bytes answer where
there is nothing above ASCII to map.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe PR adds conditional tests for Unicode-aware and ASCII-only string case behavior. It covers case conversion, swapcase, case comparison, no-op bang methods, unchanged non-ASCII bytes, and malformed byte sequences. ChangesString case behavior tests
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR adds targeted tests for ASCII case-conversion behavior without changing production code or runtime configuration. The reported builds pass with no failures or crashes, so no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
build_config/ci/gcc-clang.rb:65-70says what theascii-casebuild is there for:The second half holds, and holds nowhere else.
mrbgems/mruby-regexp/test/ascii_case.rb:12opens with
skip unless __ENCODING__ == "UTF-8", so thebyte-stringbuild reachesneither of its blocks and this build is their only home.
The first half asserts nothing. Every assertion that would show the narrowing is gated
off rather than mirrored:
test/t/string.rb:433,450,468,482,497end if UNICODECASEmrbgems/mruby-string-ext/test/string.rb:152,327skip unless UNICODECASEmrbgems/mruby-encoding/test/string.rb:490... if UNICODECASESo the conversion is held to "nothing raised" rather than to an answer. Counted against
the build beside it,
ascii-casereports a Total of 2332 wherebintestreports 2336,and none of the four blocks that went missing came back as a mirror. Nothing in any
build configuration pins this:
Fix
Gate the mirrors the other way.
UNICODECASEis false both underMRB_USE_ASCII_CASEand on a build reading its strings as bytes, so one addition covers both configurations,
and each block sits beside the Unicode block it answers.
Core holds
String#downcase,#upcaseand#capitalize, and asks for the bytes of arun that spells no character handed back, the
ArgumentErrorsuch a run draws elsewherebelonging to the walk over characters. mruby-string-ext holds
String#swapcaseand#casecmp?. mruby-encoding asks what the bytes of"Ä"read as UTF-8 answer, which iswhat the same bytes read as bytes answer where there is nothing above ASCII to map.
Verification
rake -m test, the mrbtest counts, one5517c30and on this branch:ci/gcc-clang,full-debugci/gcc-clang,bintestci/gcc-clang,cxx_abici/gcc-clang,byte-stringci/gcc-clang,ascii-casebuild_config/default.rbKOandCrashare 0 in every column. The three builds that convert case by Unicodegain the two blocks in mruby-string-ext as Skip; the three that convert by ASCII, which
default.rbis one of, gain three blocks that run. The bintests are unchanged, 106 OKin
default.rband the same in thebintestbuild.Thirteen of the twenty one new assertions answer differently on a build converting by
Unicode, which is the narrowing they are there to show. The other eight pin that the
ASCII half still converts, and answer alike either way.
Environment
Details
The optimization level is not the same in every build, so these are the lines that
actually compiled
src/string.c, with-MMD -c,-Iand-odropped.cxx_abicompiles with
gcc -x c++, not withg++;g++only links.🤖 Generated with Claude Code
https://claude.ai/code/session_01PiFpCR4tWrc5iWH8DRfNeQ
Summary by CodeRabbit
swapcase,casecmp?, and bang methods, including unchanged-result behavior.