mirror of
https://github.com/golang/go
synced 2024-10-03 06:11:21 -06:00
exp/gotype: added many more tests
gotype can now handle much of the standard library. - marked packages which have type checker issues - this CL depends on CL 6846131 R=rsc CC=golang-dev https://golang.org/cl/6850130
This commit is contained in:
parent
69d0f0cc47
commit
e93bdd998c
@ -5,20 +5,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"go/build"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func runTest(t *testing.T, path, pkg string) {
|
||||
func runTest(t *testing.T, path string) {
|
||||
exitCode = 0
|
||||
*pkgName = pkg
|
||||
*recursive = false
|
||||
|
||||
if pkg == "" {
|
||||
*recursive = false
|
||||
if suffix := ".go"; strings.HasSuffix(path, suffix) {
|
||||
// single file
|
||||
path = filepath.Join(runtime.GOROOT(), "src/pkg", path)
|
||||
path, file := filepath.Split(path)
|
||||
*pkgName = file[:len(file)-len(suffix)]
|
||||
processFiles([]string{path}, true)
|
||||
} else {
|
||||
processDirectory(path)
|
||||
// package directory
|
||||
// TODO(gri) gotype should use the build package instead
|
||||
pkg, err := build.Import(path, "", 0)
|
||||
if err != nil {
|
||||
t.Errorf("build.Import error for path = %s: %s", path, err)
|
||||
return
|
||||
}
|
||||
// TODO(gri) there ought to be a more direct way using the build package...
|
||||
files := make([]string, len(pkg.GoFiles))
|
||||
for i, file := range pkg.GoFiles {
|
||||
files[i] = filepath.Join(pkg.Dir, file)
|
||||
}
|
||||
*pkgName = pkg.Name
|
||||
processFiles(files, true)
|
||||
}
|
||||
|
||||
if exitCode != 0 {
|
||||
@ -26,26 +44,167 @@ func runTest(t *testing.T, path, pkg string) {
|
||||
}
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
path string
|
||||
pkg string
|
||||
}{
|
||||
var tests = []string{
|
||||
// individual files
|
||||
{"testdata/test1.go", ""},
|
||||
"exp/gotype/testdata/test1.go",
|
||||
|
||||
// directories
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/ast"), "ast"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/build"), "build"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/doc"), "doc"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/parser"), "parser"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/printer"), "printer"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/scanner"), "scanner"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/go/token"), "token"},
|
||||
{filepath.Join(runtime.GOROOT(), "src/pkg/exp/types"), "types"},
|
||||
// Note: packages that don't typecheck yet are commented out
|
||||
// "archive/tar", // investigate
|
||||
"archive/zip",
|
||||
|
||||
"bufio",
|
||||
"bytes",
|
||||
|
||||
"compress/bzip2",
|
||||
"compress/flate",
|
||||
"compress/gzip",
|
||||
"compress/lzw",
|
||||
"compress/zlib",
|
||||
|
||||
"container/heap",
|
||||
"container/list",
|
||||
"container/ring",
|
||||
|
||||
"crypto",
|
||||
"crypto/aes",
|
||||
"crypto/cipher",
|
||||
"crypto/des",
|
||||
"crypto/dsa",
|
||||
"crypto/ecdsa",
|
||||
"crypto/elliptic",
|
||||
"crypto/hmac",
|
||||
"crypto/md5",
|
||||
"crypto/rand",
|
||||
"crypto/rc4",
|
||||
"crypto/rsa",
|
||||
"crypto/sha1",
|
||||
"crypto/sha256",
|
||||
"crypto/sha512",
|
||||
"crypto/subtle",
|
||||
"crypto/tls",
|
||||
// "crypto/x509", // investigate
|
||||
"crypto/x509/pkix",
|
||||
|
||||
"database/sql",
|
||||
"database/sql/driver",
|
||||
|
||||
"debug/dwarf",
|
||||
"debug/elf",
|
||||
"debug/gosym",
|
||||
"debug/macho",
|
||||
"debug/pe",
|
||||
|
||||
"encoding/ascii85",
|
||||
"encoding/asn1",
|
||||
"encoding/base32",
|
||||
"encoding/base64",
|
||||
// "encoding/binary", // complex() doesn't work yet
|
||||
"encoding/csv",
|
||||
// "encoding/gob", // complex() doesn't work yet
|
||||
"encoding/hex",
|
||||
"encoding/json",
|
||||
"encoding/pem",
|
||||
"encoding/xml",
|
||||
|
||||
"errors",
|
||||
"expvar",
|
||||
"flag",
|
||||
"fmt",
|
||||
|
||||
"exp/types",
|
||||
"exp/gotype",
|
||||
|
||||
"go/ast",
|
||||
"go/build",
|
||||
// "go/doc", // variadic parameters don't work yet fully
|
||||
"go/format",
|
||||
"go/parser",
|
||||
"go/printer",
|
||||
"go/scanner",
|
||||
"go/token",
|
||||
|
||||
"hash/adler32",
|
||||
// "hash/crc32", // investigate
|
||||
"hash/crc64",
|
||||
"hash/fnv",
|
||||
|
||||
"image",
|
||||
"image/color",
|
||||
"image/draw",
|
||||
"image/gif",
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
|
||||
"index/suffixarray",
|
||||
|
||||
"io",
|
||||
// "io/ioutil", // investigate
|
||||
|
||||
"log",
|
||||
"log/syslog",
|
||||
|
||||
"math",
|
||||
// "math/big", // investigate
|
||||
// "math/cmplx", // complex doesn't work yet
|
||||
"math/rand",
|
||||
|
||||
"mime",
|
||||
"mime/multipart",
|
||||
|
||||
// "net", // depends on C files
|
||||
"net/http",
|
||||
"net/http/cgi",
|
||||
// "net/http/fcgi", // investigate
|
||||
"net/http/httptest",
|
||||
"net/http/httputil",
|
||||
// "net/http/pprof", // investigate
|
||||
"net/mail",
|
||||
// "net/rpc", // investigate
|
||||
"net/rpc/jsonrpc",
|
||||
"net/smtp",
|
||||
"net/textproto",
|
||||
"net/url",
|
||||
|
||||
// "path", // variadic parameters don't work yet fully
|
||||
// "path/filepath", // investigate
|
||||
|
||||
// "reflect", // investigate
|
||||
|
||||
"regexp",
|
||||
"regexp/syntax",
|
||||
|
||||
"runtime",
|
||||
// "runtime/cgo", // import "C"
|
||||
"runtime/debug",
|
||||
"runtime/pprof",
|
||||
|
||||
"sort",
|
||||
// "strconv", // investigate
|
||||
"strings",
|
||||
|
||||
// "sync", // platform-specific files
|
||||
// "sync/atomic", // platform-specific files
|
||||
|
||||
// "syscall", // platform-specific files
|
||||
|
||||
"testing",
|
||||
"testing/iotest",
|
||||
"testing/quick",
|
||||
|
||||
"text/scanner",
|
||||
"text/tabwriter",
|
||||
// "text/template", // variadic parameters don't work yet fully
|
||||
// "text/template/parse", // variadic parameters don't work yet fully
|
||||
|
||||
// "time", // platform-specific files
|
||||
"unicode",
|
||||
"unicode/utf16",
|
||||
"unicode/utf8",
|
||||
}
|
||||
|
||||
func Test(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
runTest(t, test.path, test.pkg)
|
||||
runTest(t, test)
|
||||
}
|
||||
}
|
||||
|
2
src/pkg/exp/gotype/testdata/test1.go
vendored
2
src/pkg/exp/gotype/testdata/test1.go
vendored
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package p
|
||||
package test1
|
||||
|
||||
func _() {
|
||||
// the scope of a local type declaration starts immediately after the type name
|
||||
|
Loading…
Reference in New Issue
Block a user