"The problem is this was never a stackoverflow question and there was never an answer for it."
Your example is so trivial, that there are definitely similar code examples. Maybe not word for word, but similar enough, that this is not really mindblowing "making things out of thin air" for me. It seems like a standard coding class example, so not surprising, that it also can make the unit tests.
Find one. Dated before 2021. In fact, according to the theory that it's statistical parroting there should be multiple examples of for loops printing out numbers being converted to unit testable functions because AI needs multiple examples of it to form the correct model.
Find one. And it doesn't have to be from stack overflow either. Just a question and answer data point.
Your example is so trivial, that there are definitely similar code examples. Maybe not word for word, but similar enough, that this is not really mindblowing "making things out of thin air" for me. It seems like a standard coding class example, so not surprising, that it also can make the unit tests.