Skip to content

test(jsonc): kill mutation-survivors in jsonc + helper paths#34

Merged
mcarvin8 merged 1 commit into
mainfrom
test/jsonc-helpers-coverage
May 11, 2026
Merged

test(jsonc): kill mutation-survivors in jsonc + helper paths#34
mcarvin8 merged 1 commit into
mainfrom
test/jsonc-helpers-coverage

Conversation

@mcarvin8
Copy link
Copy Markdown
Owner

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).

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>
@mcarvin8 mcarvin8 merged commit e14816d into main May 11, 2026
9 checks passed
@mcarvin8 mcarvin8 deleted the test/jsonc-helpers-coverage branch May 11, 2026 16:30
@mcarvin8 mcarvin8 mentioned this pull request May 11, 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.

1 participant