=== RUN TestLineNumber
--- PASS: TestLineNumber (0.00s)
The line number is wrong - it should be 7, not 6.
The testing package internally uses runtime.Caller(3) to identify the user code calling the testing.T logging function. It appears that the log := t.Log line is implicitly creating a closure, i.e. adding to the depth of the call stack, resulting in an incorrect line number.
The text was updated successfully, but these errors were encountered:
(I have put the test code inside hex_test.go. Let's ignore that)
The testing.(*common).Log-fm indicates that a closure is being created the moment something like fn := t.Log is done.
And what is more interesting is it persists across function calls. Notice that the Log-fm line is at 29 and the actual call is at 44. That is because it is happening in another Test function altogether.