This sounds a lot like Baseline Acceptance Driven Testing/Development
I don’t like it. Did the function actually print out what it did, or did it say one thing and do another? Will it report accurately what it is doing in all branches? Does it even print out what it thinks it is outputting? There could be a bug in the trace line itself. Without reading the code, who knows. We just made the function and the test more complicated. If we just use traditional unit testing of the input and output values, input A = output B, and C = D, then with enough cases we can prove it behaves correctly. If we find a case that fails later we add it to the unit test and do a bug fix that satisfies all known cases.