TestPkgKindOf

This commit is contained in:
xushiwei
2024-04-29 11:58:48 +08:00
parent bb1da81a01
commit 637db665c3

View File

@@ -17,6 +17,7 @@
package cl package cl
import ( import (
"go/constant"
"go/types" "go/types"
"testing" "testing"
@@ -44,6 +45,21 @@ func TestPkgKind(t *testing.T) {
} }
} }
func TestPkgKindOf(t *testing.T) {
if v := PkgKindOf(types.Unsafe); v != PkgDeclOnly {
t.Fatal("PkgKindOf unsafe:", v)
}
pkg := types.NewPackage("foo", "foo")
pkg.Scope().Insert(
types.NewConst(
0, pkg, "LLGoPackage", types.Typ[types.String],
constant.MakeString("noinit")),
)
if v := PkgKindOf(pkg); v != PkgNoInit {
t.Fatal("PkgKindOf foo:", v)
}
}
func TestIsAny(t *testing.T) { func TestIsAny(t *testing.T) {
if isAny(types.Typ[types.UntypedInt]) { if isAny(types.Typ[types.UntypedInt]) {
t.Fatal("isAny?") t.Fatal("isAny?")