Skip to content

test: add edge-case coverage for UTF-8 keys, regex, mixed types#144

Draft
Koan-Bot wants to merge 1 commit into
garu:masterfrom
Koan-Bot:koan.atoomic/test-edge-cases
Draft

test: add edge-case coverage for UTF-8 keys, regex, mixed types#144
Koan-Bot wants to merge 1 commit into
garu:masterfrom
Koan-Bot:koan.atoomic/test-edge-cases

Conversation

@Koan-Bot

Copy link
Copy Markdown
Contributor

What

Add t/28-edge-cases.t with 69 tests covering previously untested code paths.

Why

Coverage analysis revealed several code paths in Clone.xs that lacked
explicit test coverage. While these paths work correctly today, regressions
could go unnoticed without dedicated tests — particularly for the UTF-8 key
handling path (HeKUTF8 + negative klen) and the hv_ksplit pre-sizing
optimization.

Test areas

  • UTF-8 hash keys: latin-1, wide characters, mixed ASCII+unicode keys
    — verifies both value correctness and UTF-8 flag preservation
  • Regex (qr//) cloning: all standard modifiers (/i, /m, /s, /x, combined)
    — verifies both stringification and functional behavior
  • Mixed-type hash values: exercises the full sv_clone type switch in a
    single structure (undef, IV, NV, PV, RV, AV, HV, CV, REGEXP)
  • Large hash correctness: 1000-key hash with mixed ASCII and UTF-8 keys
    — exercises hv_ksplit pre-sizing path
  • Nested blessed objects: multi-level class preservation for hashrefs,
    arrayrefs, and scalarrefs
  • Shared reference identity: verifies that multiply-referenced SVs share
    a single clone
  • Deferred weakening: strong+weak refs to the same target

Testing

All 428 tests pass (29 files including this new one).


Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Add t/28-edge-cases.t with 69 tests covering previously untested
code paths in Clone.xs:

- UTF-8 hash key preservation (HeKUTF8 + negative klen in hv_store)
- Regex (qr//) cloning with /i, /m, /s, /x modifiers
- Mixed-type hash values (full sv_clone type switch)
- Large hash correctness (hv_ksplit pre-sizing with 1000 keys)
- Nested blessed objects at multiple levels
- Shared reference identity preservation across clone graph
- Deferred weakening with strong+weak refs to same target

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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