Skip to content

Commit

Permalink
TestImportError
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Nov 21, 2023
1 parent de715e2 commit 6974087
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"go/types"
"log"
"math/big"
"strings"
"testing"
"unsafe"

Expand Down Expand Up @@ -1049,6 +1050,21 @@ func TestImportPkg(t *testing.T) {
}
}

func TestImportError(t *testing.T) {
defer func() {
err := recover()
if err == nil {
t.Fatal("no error")
}
if !strings.HasPrefix(err.(error).Error(), "package bad is not in") {
t.Fatal("bad import error", err)
}
}()
pkg := NewPackage("github.com/goplus/gox", "gox", gblConf)
f := &File{importPkgs: make(map[string]*PkgRef)}
f.importPkg(pkg, "bad", nil)
}

func TestForRangeStmtPanic(t *testing.T) {
defer func() {
if e := recover(); e != nil {
Expand Down
1 change: 0 additions & 1 deletion error_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1381,5 +1381,4 @@ type M struct {
MemberVal("x", source("m.x", 3, 10)).Call(1).EndStmt().
End()
})

}

0 comments on commit 6974087

Please sign in to comment.