You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
1. bug.go:
package bug
import "fmt"
func Table() {
fmt.Println(" 1")
fmt.Println(" 10")
fmt.Println(" 100")
fmt.Println("1000")
}
2. bug_test.go:
package bug
func ExampleTable() {
Table()
//Output:
// 1
// 10
// 100
//1000
}
3. go test
What is the expected output?
PASS
What do you see instead?
--- FAIL: ExampleTable (11.138us)
got:
1
10
100
1000
want:
1
10
100
1000
FAIL
exit status 1
FAIL bug 0.008s
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
linux_amd64
Which version are you using? (run 'go version')
go version devel +8153882a36e8 Wed Apr 03 11:13:40 2013 -0700 linux/amd64
Please provide any additional information below.
The problem seems to require at least one line of example output without leading space,
and then at least one line other than the first line with leading space.
While example examples in the testing package doc show leading spaces, the doc does not
say this is required and in fact says that the comparison ignores leading and trailing
space.
Further, the failure report shows a confusing mix of trimmed and untrimmed lines
(perhaps related to the incorrect fail result.)
The text was updated successfully, but these errors were encountered:
If you write your example function using a space after the "//" comments (as is the
common convention), it works fine:
func ExampleTable() {
Table()
// Output:
// 1
// 10
// 100
// 1000
}
I think this is a bad interaction with the go parser's comment parsing code and your
comment style. Changing the comment style fixes it. I'm not sure whether we should take
this further.
by soniakeys:
The text was updated successfully, but these errors were encountered: