Comment on Me after I got fired
frezik@midwest.social 1 year agorand()
will be infrequent < 10
(at least ten in 2^15 times, if not exponentially more), so automated tests are likely to pass. If they don’t, they’re likely to pass on the second try, and then everyone shrugs and continues. If it’s buried in 500 other lines, then it’s likely the code reviewer will give it all a quick scan and say “it’s fine”. It’s the three line diffs that get lots of scrutiny.
In other words, you seem to have a lot more faith in the process than I do.
killeronthecorner@lemmy.world 1 year ago
rand will be called every time true is used, which could be hundreds of times for all we know
frezik@midwest.social 1 year ago
If it’s a 16-bit integer platform, it might hit every once in a while.
If it’s a 32-bit integer platform, it’ll hit very rarely.
If it’s a 64-bit integer platform, someone would have to do the math with some reasonable assumptions, but I wouldn’t be surprised if it would never hit before the universe becomes nothing but black holes.
Morphit@feddit.uk 1 year ago
The point being made is that it also depends how often the ‘true’ value gets used in the code. Tests might only evaluate it a few times per run, or they could cause billions of evaluations per run. You can’t know the probability of a test failure without knowing the occurrence rate of that expression.
killeronthecorner@lemmy.world 1 year ago
Yes you’re correct, this was the point I was making.