4 ms·
What your tests will miss is the invalid data that was constructed in one corner of the codebase // apply special discount newPaymentInfo = {value: old
by bccdee 1y ago
What your tests will miss is the invalid data that was constructed in one corner of the codebase
// apply special discount
newPaymentInfo = {value: oldPaymentInfo.value / 2}
newPaymentInfo[tax] = applyRegionalTax(newPaymentInfo.value)
return newPaymentInfo
which only gets parsed by another corner of the codebase at runtime.
// apply tax to tips only in some regions
if (taxableTips) {
paymentInfo.tip += applyRegionalTax(paymentInfo.value)
// ERROR: tip is undefined (instead of zero)
}
You can't validate everything all the time, and if you try, it's easy for that validation to fall out of sync with the actual demands of the underlying logic. Errors like this crop up easily while refactoring. That's why one of the touted benefits of Rust's type system is "fearless refactoring."