#1 the two functions need to behave identically according to the syntax of the language.#2 this is how working code operates, so testing needs to be able to handle it.at a guess; 'testing' would appear to have some non-compliant reflection going on, in this edge-case.
but anyway; your reply has no relevance i can decern, and replying like this can put off useful comments. please don't get huffy i don't have the time/interest, just don't comment anymore.On Monday, 2 May 2022 at 03:32:46 UTC+1 peterGo wrote:It looks like you have a bug in your code.
"In tests, standard output is accumulated during execution and dumped to standard output when done."
"Example functions may include a concluding line comment that begins with "Output:" and is compared with the standard output of the function when the tests are run."
In ExampleMain(), you improperly used the os.Stdout variable value as of the testing package initialization.
In ExampleMain2(), you properly used the os.Stdout variable value as of when the function was run.
testing package
https://pkg.go.dev/testing@latest
PeterOn Sunday, May 1, 2022 at 8:03:29 PM UTC-4 psi....@gmail.com wrote:this caught me out, is it a bug?
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/d8654a21-e060-4bee-842f-e6eb41d21878n%40googlegroups.com.
i see, thanksthe implementation of 'go test' (which the playground runs auto-magically.) replaces os.Stdout with a new reference behind the scenes before running the func, but after making global vars, so the code as written isn't strictly 'go' anymore.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/994e20cc-c1c5-4e8c-a022-16a2e83a85a4n%40googlegroups.com.