Skip to content

test(stable-api): add comprehensive edge-case parity tests#737

Merged
ianks merged 2 commits into
mainfrom
test/stable-api-edge-cases
Apr 23, 2026
Merged

test(stable-api): add comprehensive edge-case parity tests#737
ianks merged 2 commits into
mainfrom
test/stable-api-edge-cases

Conversation

@ianks

@ianks ianks commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds 108 new parity tests covering divergence vectors not exercised by the original suite
  • All tests pass locally against the dev Ruby (3.4, macOS ARM64)

What's covered

Area Edge cases added
rstring_len empty, NUL mid-string ("foo\x00bar" → len=7), embed/heap boundary (23 vs 24 bytes), binary bytes, multibyte UTF-8, frozen
rstring_ptr / rstring_end embedded vs heap; ptr + len == end invariant
rarray_len / rarray_const_ptr empty, embed max (3), first heap (4), large (1000), special VALUEs, nested
num2dbl NaN (custom is_nan()assert_eq! silently passes for NaN), −0.0 bit-exact sign, −Inf, subnormal, MIN_POSITIVE
dbl2num −0.0 roundtrip sign, NaN roundtrip, −Inf roundtrip, negative flonum
rhash_size exactly 8 (AR max), exactly 9 (ST threshold), after delete, string/mixed keys
encoding_get BINARY, US-ASCII; UTF-8 vs BINARY differ assertion
frozen_p Symbol/Integer/Float (always frozen), nil/true/false, mutable vs frozen String/Hash
special_const_p flonum (immediate ✓), heap Float (not immediate ✗), Bignum, Array
nil_p / rb_test Ruby truthiness: 0, "", [], {} are all truthy — common C/Java gotcha
type_p correct + wrong type for String, Bignum, Float, Hash (custom two-arg tests)
builtin_type Bignum, heap Float, Regexp, Class, Module, Struct
rstring_interned_p dynamic (false) vs frozen literal (true)
bignum_* FIXNUM_MAX+1, FIXNUM_MIN−1, 2**128
num2long / num2ulong FIXNUM_MAX, FIXNUM_MIN (LP64 only)

Test plan

  • All 295 tests pass locally (cargo test -p rb-sys-tests)
  • CI green on Ruby 2.7 → master × Linux / macOS / Windows

🤖 Generated with Claude Code

ianks added 2 commits April 23, 2026 13:21
Covers divergence vectors not exercised by the original suite:

- rstring_len: empty string, embedded NUL mid-string (len=7 not 3),
  exact embed/heap boundary (23 vs 24 bytes), binary bytes, multibyte
  UTF-8, frozen strings
- rstring_ptr/rstring_end: embedded vs heap, ptr+len == end invariant
- rarray_len/rarray_const_ptr: empty, embed max (3), first heap (4),
  large (1000), special VALUE elements, nested arrays
- num2dbl: NaN (custom is_nan check since NaN!=NaN), -0.0 bit-exact
  sign preservation, -Inf, negative flonum, subnormal, MIN_POSITIVE
- dbl2num: -0.0 roundtrip sign check, NaN roundtrip, -Inf roundtrip,
  negative flonum
- rhash_size: exactly 8 (AR max), exactly 9 (ST threshold), after
  delete, string keys, mixed keys, nested values
- rhash_empty_p: after deleting all entries
- encoding_get: BINARY, US-ASCII; UTF-8 vs BINARY differ assertion
- frozen_p: Symbol/Integer/Float (always frozen), nil/true/false,
  mutable vs frozen String and Hash
- special_const_p: nil, true, false, fixnum 0, large fixnum, flonum
  (immediate), heap Float (not immediate), Bignum, Array
- nil_p: false/0/""/[] all return false
- rb_test: nil/false falsy; 0/""/[]/{}  all truthy (Ruby gotcha)
- type_p: correct and wrong type for String, Bignum, Float, Hash
- rbasic_class: String, Hash, Bignum, heap Float
- builtin_type: Bignum, heap Float, Regexp, Class, Module, Struct
- rstring_interned_p: dynamic (false) vs frozen literal (true)
- bignum_positive_p/negative_p: FIXNUM_MAX+1, FIXNUM_MIN-1, 2**128
- num2long/num2ulong: FIXNUM_MAX, FIXNUM_MIN (LP64 only)
@ianks ianks force-pushed the test/stable-api-edge-cases branch from d9973f8 to 22279e2 Compare April 23, 2026 17:21
@ianks ianks merged commit 14f072d into main Apr 23, 2026
60 checks passed
@ianks ianks deleted the test/stable-api-edge-cases branch April 23, 2026 17:21
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