News for hackers. Stuff that matters.
Re:Programming with Natural Language Is Going to Work (2010) by ahtihn on Wednesday May 24, 2023 @04:23PM (#36063408)
> Fully Correct

It's not though. It doesn't print the values anymore, so the behavior isn't the same.

Refactoring isn't allowed to change behavior.

Re:Programming with Natural Language Is Going to Work (2010) by byby on Wednesday May 24, 2023 @04:37PM (#36063562)
It is. There is literally zero other way to make that function unit testable. What are you gonna compare that data with in a test if it's thrown into IO?

By definition all unit testable functions have to return data that can be asserted. You throw that data to IO it's not unit testable.

IO is testable via an integration tests. But not unit tests. Which is what my query exactly specified. I specified unit tests.

Re:Programming with Natural Language Is Going to Work (2010) by ahtihn on Wednesday May 24, 2023 @05:26PM (#36064065)
That doesn't change the fact that it's not a valid refactoring. If you can't make it unit testable without changing behavior, then it should tell you that.

Replacing a function that does `print("hello world")` with a function that does `return "hello world"` isn't a valid way to make it unit testable.

Re:Programming with Natural Language Is Going to Work (2010) by byby on Wednesday May 24, 2023 @06:31PM (#36064682)
Alright fine, I can concede to this. ChatGPT should not have given me the best alternative but it should have given me the exact technically correct answer. You're right.