cl: TestImport/TestVarOf
This commit is contained in:
@@ -17,7 +17,11 @@
|
||||
package cl
|
||||
|
||||
import (
|
||||
"go/types"
|
||||
"testing"
|
||||
|
||||
llssa "github.com/goplus/llgo/ssa"
|
||||
"golang.org/x/tools/go/ssa"
|
||||
)
|
||||
|
||||
func TestIgnoreName(t *testing.T) {
|
||||
@@ -25,3 +29,27 @@ func TestIgnoreName(t *testing.T) {
|
||||
t.Fatal("ignoreName failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestImport(t *testing.T) {
|
||||
var ctx context
|
||||
pkg := types.NewPackage("foo", "foo")
|
||||
ctx.importPkg(pkg)
|
||||
}
|
||||
|
||||
func TestVarOf(t *testing.T) {
|
||||
defer func() {
|
||||
if r := recover(); r == nil {
|
||||
t.Fatal("varOf: no error?")
|
||||
}
|
||||
}()
|
||||
prog := llssa.NewProgram(nil)
|
||||
pkg := prog.NewPackage("foo", "foo")
|
||||
pkgTypes := types.NewPackage("foo", "foo")
|
||||
ctx := &context{
|
||||
pkg: pkg,
|
||||
goTyps: pkgTypes,
|
||||
}
|
||||
ssaPkg := &ssa.Package{Pkg: pkgTypes}
|
||||
g := &ssa.Global{Pkg: ssaPkg}
|
||||
ctx.varOf(g)
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ func (p *context) compileFunc(pkg llssa.Package, pkgTypes *types.Package, f *ssa
|
||||
return
|
||||
}
|
||||
if debugInstr {
|
||||
log.Println("==> NewFunc", f.Name(), name, "type:", sig.Recv(), sig)
|
||||
log.Println("==> NewFunc", name, "type:", sig.Recv(), sig)
|
||||
}
|
||||
fn := pkg.NewFunc(name, sig)
|
||||
p.inits = append(p.inits, func() {
|
||||
|
||||
Reference in New Issue
Block a user