This repository was archived by the owner on Aug 7, 2026. It is now read-only.
Repository navigation
Commit e241048
test: cover generateData's per-dtype element width
Closes the gap noted when the dead `bytesPerElement` table was removed:
nothing asserted that generateData selects the right typed-array constructor
for each dtype. The existing checks could not see it, because a wrong
constructor still returns exactly sizeBytes bytes of non-zero data.
Adds a `generateData element width` block with two kinds of assertion.
Per dtype, the returned bytes are re-viewed through the constructor the dtype
is expected to use, and the opening run is checked for the shape generateData
actually writes: sin(i * 0.01) scaled to the dtype's range climbs from zero to
its first peak at element 157, so read at the correct width the series starts
at 0, ends the quarter period above 0, and never falls back. Read at any other
width the same bytes reinterpret into unrelated values and lose that shape.
Across dtypes, the byte patterns at a fixed size must all differ, which pins
the weaker property that the dtype argument affects the output at all.
The expected dtype -> constructor mapping is restated in the test rather than
exported from data.ts on purpose. Importing the table the implementation uses
would make the assertion tautological; restating it means a change there fails
here instead of being mirrored automatically.
Verified by mutation rather than by inspection:
- constructors swapped so every dtype builds an Int8Array, amplitudes left
correct: the three non-int8 width tests fail, int8 correctly still passes,
and every pre-existing test in the file passes - which is the gap.
- generateData made to ignore `type` for both constructor and amplitude:
the same three fail plus the distinctness test.
Note the distinctness test caught nothing the width tests missed under either
mutant. Kept because it states the "dtype must matter" invariant directly and
runs in 31ms, but it is subsumed on current evidence.
Benchmark suite goes 43 -> 48 tests. `vp check` clean; benchmark typecheck
unchanged at 8 pre-existing TS2351 CodecConstructor errors.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ee1772c commit e241048
1 file changed
Lines changed: 81 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
3 | 33 | | |
4 | 34 | | |
5 | 35 | | |
| |||
19 | 49 | | |
20 | 50 | | |
21 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
22 | 102 | | |
23 | 103 | | |
24 | 104 | | |
| |||
0 commit comments