1
0
mirror of https://github.com/golang/go synced 2024-11-19 00:44:40 -07:00

astutil: add new broken test

Tests will still pass because it's marked as known broken,
but it will log the unexpected for now.

R=golang-dev, crawshaw
CC=golang-dev
https://golang.org/cl/27330043
This commit is contained in:
Brad Fitzpatrick 2013-11-16 14:53:18 -08:00
parent e785f050b6
commit a284a61701

View File

@ -35,6 +35,7 @@ type test struct {
pkg string pkg string
in string in string
out string out string
broken bool // known broken
} }
var addTests = []test{ var addTests = []test{
@ -168,6 +169,27 @@ import (
fmtpkg "fmt" fmtpkg "fmt"
"os" "os"
) )
`,
},
{
broken: true,
name: "struct comment",
pkg: "time",
in: `package main
// This is a comment before a struct.
type T struct {
t time.Time
}
`,
out: `package main
import "time"
// This is a comment before a struct.
type T struct {
t time.Time
}
`, `,
}, },
} }
@ -177,10 +199,14 @@ func TestAddImport(t *testing.T) {
file := parse(t, test.name, test.in) file := parse(t, test.name, test.in)
AddNamedImport(file, test.renamedPkg, test.pkg) AddNamedImport(file, test.renamedPkg, test.pkg)
if got := print(t, test.name, file); got != test.out { if got := print(t, test.name, file); got != test.out {
if test.broken {
t.Logf("%s is known broken:\ngot: %s\nwant: %s", test.name, got, test.out)
} else {
t.Errorf("%s:\ngot: %s\nwant: %s", test.name, got, test.out) t.Errorf("%s:\ngot: %s\nwant: %s", test.name, got, test.out)
} }
} }
} }
}
func TestDoubleAddImport(t *testing.T) { func TestDoubleAddImport(t *testing.T) {
file := parse(t, "doubleimport", "package main\n") file := parse(t, "doubleimport", "package main\n")