Like I presented in my previous issue, test coverage is misleading.
It would be a lot more valuable to write property-based tests, for example with fast-check
Another very valuable addition would be to add corresponding contracts (properties you want about a function) directly in the jsdocs. It could look like:
/**
* @pre array.length > 0
* @pre array.every((x, i) => i === 0 || x >= array[i - 1])
* @post (result) => result === -1 || array[result] === key
*/
function binarySearch(array: number[], key: number): number {
let lo = 0, hi = array.length - 1;
while (lo <= hi) {
const mid = (lo + hi) >> 1;
if (array[mid] === key) return mid;
if (array[mid] < key) lo = mid + 1;
else hi = mid - 1;
}
return -1;
}
Then, the agent would translate it to a test and back.
I noticed the agent finds bugs a lot faster when invariants are written this way.
Like I presented in my previous issue, test coverage is misleading.
It would be a lot more valuable to write property-based tests, for example with fast-check
Another very valuable addition would be to add corresponding contracts (properties you want about a function) directly in the jsdocs. It could look like:
Then, the agent would translate it to a test and back.
I noticed the agent finds bugs a lot faster when invariants are written this way.