Skip to content

Commit

Permalink
Merge pull request #1800 from xushiwei/q
Browse files Browse the repository at this point in the history
TestTypeAndValue, TestConvErr
  • Loading branch information
xushiwei committed Mar 8, 2024
2 parents 89f4bb0 + 3097f6a commit f39646c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cl/internal/typesutil/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func TestTypeAndValue(t *testing.T) {
if ret.Value == nil {
t.Fatal("NewTypeAndValueForValue: not const?")
}
ret = NewTypeAndValueForValue(ty, constant.MakeInt64(1), Constant)
if ret.Value == nil {
t.Fatal("NewTypeAndValueForValue: not const?")
}
ret = NewTypeAndValueForCallResult(tyInt, nil)
if !ret.IsValue() {
t.Fatal("NewTypeAndValueForCall: not value?")
Expand Down
18 changes: 18 additions & 0 deletions x/typesutil/builtin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package typesutil

import (
"errors"
"testing"

"github.com/goplus/gogen"
)

func TestConvErr(t *testing.T) {
e := errors.New("foo")
if ret, ok := convErr(nil, &gogen.ImportError{Err: e}); !ok || ret.Msg != "foo" {
t.Fatal("convErr:", ret, ok)
}
if _, ok := convErr(nil, e); ok {
t.Fatal("convErr: ok?")
}
}

0 comments on commit f39646c

Please sign in to comment.