Okay, so no my finest moment coding here.
I should note that I’m on the free plan, using Claude Sonnet here.
I have some code which is fairly complicated, and has a section where I have:
if conditionAHolds {
...
} else {
thing1
thing2
if conditionAHolds {
codeWhichIsNotCovered
}
}
And I’m sure you see immediately why codeWhichIsNotCovered
never shows up in my coverage tool as executed with my test suite. Like I say, not the best bit of code ever.
I asked Cody why, and it told me that I needed a test case to cover it, and wrote a perfectly cromulent test case which… didn’t hit the line in question when run.
So I told it, “nope, that doesn’t cover that line”, and it apologized and promptly gave me pretty much exactly the same test again.
Suddenly, the light went on, and (in case you haven’t had your coffee/tea yet) I realized that in the initial “else” case, conditionAHolds
can’t possibly be true. So the codeWhichIsNotCovered
is literally impossible to get to.
This seems to point out that current AIs are, indeed, just doing textual analysis, not logical analysis, so it (in effect) can’t understand the logic error I made here.
So… curious if people have run across this kind of thing, and whether people have seen solutions like this found by one or more of the AIs.
Thanks!