test(jsonc): kill mutation-survivors in jsonc + helper paths#34
Merged
Conversation
Close coverage gaps in `disassemble.rs` and `reassemble.rs` that the cargo-mutants baseline flagged as missed mutants. All assertions verify existing behavior; no production code changes. disassemble.rs: - `unique_id_basename`: cover the `Value::Number` and `Value::Bool` match arms (previously only `Value::String` was exercised), plus the fallthrough for missing / unsupported fields. - `sanitize`: assert allowed-char preservation (`-`, `_`, `.`, alnum) and replacement of everything else with `_`, pinning each disjunct in the predicate. - `hash_string` / `hash_value`: assert determinism, hex output, length, and input-sensitivity (pins both functions against constant-return mutants like `Default::default()` or `"xyzzy"`). - `digit_width`: assert the floor of 4 and the growth above 4-digit counts (kills `/=`→`%=`, `+=`→`*=`, and similar arithmetic mutants). - `leading_comment_start`: cover `start == 0` (kills `>`→`>=`, which loops forever via `saturating_sub`), consecutive comment walk-back, and stop-at-non-comment-line. - `line_end`: pin `pos + idx` arithmetic and the no-newline fallback. - `jsonc_segment_with_comma`: assert CRLF / LF stripping via `trim_matches` (kills `||`→`&&`, which collapses the predicate). - `disassemble_file`: assert pre-existing output is preserved when `pre_purge = false` (kills `&&`→`||` on `pre_purge && exists()`). reassemble.rs: - `leading_comment_start`, `line_end`, `jsonc_segment_with_comma`: same kill-pattern coverage as the disassemble side. - `render_jsonc_property`: assert CRLF normalization on the value. - `render_jsonc_array_element`: assert the first line is not prefixed with a newline (kills `>`→`>=` on `idx > 0`). - `default_output_path`: assert the path is built from `Meta::source_filename` with the requested output extension, and the fallback path when `source_filename` is `None` (kills the `Ok(Default::default())` constant-return mutant). - `reassemble`: round-trip through a nested target path to assert the parent directory is created (kills `delete !` on the `!parent.as_os_str().is_empty()` guard). Co-authored-by: Cursor <cursoragent@cursor.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.
Close coverage gaps in
disassemble.rsandreassemble.rsthat the cargo-mutants baseline flagged as missed mutants. All assertions verify existing behavior; no production code changes.disassemble.rs:
unique_id_basename: cover theValue::NumberandValue::Boolmatch arms (previously onlyValue::Stringwas exercised), plus the fallthrough for missing / unsupported fields.sanitize: assert allowed-char preservation (-,_,., alnum) and replacement of everything else with_, pinning each disjunct in the predicate.hash_string/hash_value: assert determinism, hex output, length, and input-sensitivity (pins both functions against constant-return mutants likeDefault::default()or"xyzzy").digit_width: assert the floor of 4 and the growth above 4-digit counts (kills/=→%=,+=→*=, and similar arithmetic mutants).leading_comment_start: coverstart == 0(kills>→>=, which loops forever viasaturating_sub), consecutive comment walk-back, and stop-at-non-comment-line.line_end: pinpos + idxarithmetic and the no-newline fallback.jsonc_segment_with_comma: assert CRLF / LF stripping viatrim_matches(kills||→&&, which collapses the predicate).disassemble_file: assert pre-existing output is preserved whenpre_purge = false(kills&&→||onpre_purge && exists()).reassemble.rs:
leading_comment_start,line_end,jsonc_segment_with_comma: same kill-pattern coverage as the disassemble side.render_jsonc_property: assert CRLF normalization on the value.render_jsonc_array_element: assert the first line is not prefixed with a newline (kills>→>=onidx > 0).default_output_path: assert the path is built fromMeta::source_filenamewith the requested output extension, and the fallback path whensource_filenameisNone(kills theOk(Default::default())constant-return mutant).reassemble: round-trip through a nested target path to assert the parent directory is created (killsdelete !on the!parent.as_os_str().is_empty()guard).