Add unit tests for String and CompiledMethod codegen primitives (BT-2150)#2175
Add unit tests for String and CompiledMethod codegen primitives (BT-2150)#2175
Conversation
… (BT-2150) String.rs was at 8.9% line coverage (14/145 lines) with only `length` and `++` tested. CompiledMethod had 0% coverage across all 6 selectors. Adds 92 new #[cfg(test)] tests to the existing primitives/mod.rs block: - String transform group: at:, uppercase, lowercase, capitalize, trim, trimLeft, trimRight, reverse, comma-concat - String search group: includes:, startsWith:, endsWith:, indexOf:, split:, splitOn:, repeat:, lines, words, replaceAll:with:, replaceFirst:with:, take:, drop:, padLeft:, padRight:, padLeft:with:, padRight:with: - String misc group: isBlank, isDigit, isAlpha, asInteger, asFloat, asAtom, asList, each:, collect:, select:, reject:, stream, withAll:, fromCodePoint:, fromCodePoints:, fromIolist:, unknown→None - String regex group (BT-709): matchesRegex:, matchesRegex:options:, firstMatch:, allMatches:, replaceRegex:with:, replaceAllRegex:with:, splitRegex: - String comparison group: =:=, /=, =/=, <, >, <=, >= - CompiledMethod: selector, source, doc, argumentCount, printString, asString, unknown→None Zero production code changes. Primitives test count: 110 → 202. 3411 total tests pass (was 3319 before BT-2147 landed array/dictionary). https://claude.ai/code/session_01T8TqFpxfyaJFntxm8GQG19
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR expands the unit test suite in ChangesCore Erlang Primitives — Tests
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/beamtalk-core/src/codegen/core_erlang/primitives/mod.rs`:
- Around line 1061-1072: The tests like test_string_split (and similar tests at
ranges 1118-1144, 1172-1222, 1491-1554) only assert substrings and can miss
regressions; update these tests to assert the exact rendered Core Erlang output
instead of loose contains() checks: use
doc_to_string(generate_primitive_bif(...)) -> result.unwrap() and then
assert_eq!(output, "<expected full Core Erlang string>") (or at minimum assert
the exact call form and full argument order/token sequence, e.g. verify
"binary':'split'(..., 'global')" including Sep, order of arguments like 'Sep'
and any N/Pat/Repl parameters). Locate these cases around the
generate_primitive_bif/document rendering usages (e.g. test_string_split) and
replace the contains() assertions with assert_eq! or precise string
equality/assertions that include the full call shape.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f2eb6188-3b3b-41c0-a347-b506ef8ad551
📒 Files selected for processing (1)
crates/beamtalk-core/src/codegen/core_erlang/primitives/mod.rs
There was a problem hiding this comment.
Pull request overview
Adds substantial unit-test coverage for Core Erlang primitive codegen mappings for String and CompiledMethod within beamtalk-core, exercising many previously-uncovered selector→BIF/codegen paths.
Changes:
- Add a large suite of
Stringprimitive tests covering transform/search/misc/comparison/regex selector mappings. - Add
CompiledMethodprimitive tests covering all supported selectors plus an unknown-selectorNonecase.
… tests (BT-2150) Address CodeRabbit and Copilot review findings: - Replace loose contains() checks with exact assert_eq! on full Core Erlang output for all multi-arg and factory String tests: split:, replaceAll:with:, replaceFirst:with:, padLeft:, padRight:, padLeft:with:, padRight:with:, matchesRegex:options:, replaceRegex:with:, replaceAllRegex:with:, withAll:, fromCodePoint:, fromCodePoints:, fromIolist:, ,/comma-concat - padLeft:with: and padRight:with: now assert both N and Ch are present in the correct argument order https://claude.ai/code/session_01T8TqFpxfyaJFntxm8GQG19
Summary
Closes BT-2150
string.rsandreflection.rs(CompiledMethod section) incrates/beamtalk-core/src/codegen/core_erlang/primitives/were both severely under-tested. Coverage data from CI run 25428951201 showed:string.rs: 8.9% (14/145 lines) — onlylengthand++exercisedreflection.rsCompiledMethod: 0% — all 6 selectors uncoveredChanges
Adds 92 tests to the existing
#[cfg(test)] mod testsblock inprimitives/mod.rs, following the exact pattern established by BT-2147 (Array + Dictionary):at:,uppercase,lowercase,capitalize,trim,trimLeft,trimRight,reverse,,concatincludes:,startsWith:,endsWith:,indexOf:,split:,splitOn:,repeat:,lines,words,replaceAll:with:,replaceFirst:with:,take:,drop:,padLeft:,padRight:,padLeft:with:,padRight:with:isBlank,isDigit,isAlpha,asInteger,asFloat,asAtom,asList,each:,collect:,select:,reject:,stream,withAll:,fromCodePoint:,fromCodePoints:,fromIolist:, unknown→NonematchesRegex:,matchesRegex:options:,firstMatch:,allMatches:,replaceRegex:with:,replaceAllRegex:with:,splitRegex:=:=,/=,=/=,<,>,<=,>=selector,source,doc,argumentCount,printString,asString, unknown→NoneZero production code changes. Primitives test count: 110 → 202.
Test plan
cargo test -p beamtalk-core— 3411 tests pass (0 failed)cargo clippy -p beamtalk-core -- -D warnings— cleancargo fmt --check -p beamtalk-core— cleanstring.rscoverage expected to rise from 8.9% to ≥95%https://claude.ai/code/session_01T8TqFpxfyaJFntxm8GQG19
Generated by Claude Code
Summary by CodeRabbit