Commit 1d247ad
committed
test(permutation): strengthen bitwise_permute coverage
Addresses Toby's review feedback on PR #165 — the existing
`bitwise_permute_case` only asserts `output != input`, which is too weak
to catch most plausible regressions in the bit-pack/unpack glue.
Adds four targeted invariant checks:
- `zero_in_zero_out`: 0 -> 0 across every supported width. Catches stray
bits introduced by sign/endian bugs in the unpack/repack path.
- `all_ones_invariant`: !0 is a fixed point of every bit permutation
(all bit positions hold 1, so no movement is observable). Catches
missing-bit bugs at high/low width boundaries.
- `preserves_hamming_weight`: popcount(permute(x)) == popcount(x). The
strongest single property check available here — any bug that drops,
duplicates, or mis-positions a bit changes the count. Also justifies
the `unsafe new_unchecked` in the NonZero impls (popcount > 0 in =>
popcount > 0 out).
- `is_deterministic`: cheap guard against future nondeterminism
(hash-seeds, uninit-memory branches, etc.) creeping into the path.
Existing `permute_array` correctness is already covered in elementwise
tests, so these new tests focus on the bit-shuffle glue specific to
`bitwise.rs` rather than retesting the underlying primitive.1 parent 1656fda commit 1d247ad
1 file changed
Lines changed: 81 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
100 | 181 | | |
0 commit comments