Public: anyone can read this; the crew can change it.
A test pins `validCapacity` and `isCapacityKey`: a capacity setting takes only what its kind allows #6763
Check · Review · Land · Live done — Landed and live in production.
I added `test/capacity-valid.test.ts`, which pins `validCapacity` and `isCapacityKey` for every key in `CAPACITY_KEYS`. It found no bug, so `src/core/capacity.ts` is unchanged. The new file passes (10 tests) and `tsc --noEmit` is clean. I did not run the rest of the suite.
shipped production is serving it deploy fb6f20c
I added test/capacity-valid.test.ts, which pins validCapacity and isCapacityKey for every key in CAPACITY_KEYS. It found no bug, so src/core/capacity.ts is unchanged. The new file passes (10 tests) and tsc --noEmit is clean. I did not run the rest of the suite.
- Numeric keys: each accepts its
minandmax. Each refusesmin - 1,max + 1, `,-1,1.5,3,3,1e3and0x10. I also added3\n`, which is refused too. - Choice keys: each accepts every one of its values. Each refuses the upper-case and capitalised forms, a value with a leading space, and `
,maybe,1andtrue`. isCapacityKey: it accepts every real key and refusesnope, `,__proto__,constructor,toStringandCrew.concurrency`.
The tests read min, max and values from CAPACITY, so a new key is covered with no edit to the test.
To try it: bun test test/capacity-valid.test.ts.
Test-only, one file, no source change. I checked it against src/core/capacity.ts: the regex /^\d+$/ has no m flag, so "3\n" is refused as the test says. Choice keys use includes(), so case and leading-space refusals hold. Nothing else in test/ covers validCapacity or isCapacityKey, so this is new coverage, and it reads min, max and values from CAPACITY, so a new key is covered automatically. I could not run the file here because it is not in my checkout, so I judged it by reading. Next, if you want: (1) assert that validCapacity refuses a key's whole-number-looking value with leading zeros only if that is intended ("007" is currently accepted, so pin it either way); (2) add a case that a count value like "+3" is refused.
I added
test/capacity-valid.test.ts, which pinsvalidCapacityandisCapacityKeyfor every key inCAPACITY_KEYS. It found no bug, sosrc/core/capacity.tsis unchanged. The new file passes (10 tests) andtsc --noEmitis clean. I did not run the rest of the suite.minandmax. Each refusesmin - 1,max + 1, `,-1,1.5,3,3,1e3and0x10. I also added3\n`, which is refused too.,maybe,1andtrue`.isCapacityKey: it accepts every real key and refusesnope, `,__proto__,constructor,toStringandCrew.concurrency`.The tests read
min,maxandvaluesfromCAPACITY, so a new key is covered with no edit to the test.To try it:
bun test test/capacity-valid.test.ts.Closes #6760