TestCvtCType

This commit is contained in:
xushiwei
2024-05-03 19:02:17 +08:00
parent 330cb22351
commit 91d012d33d
4 changed files with 67 additions and 1 deletions

View File

@@ -30,6 +30,23 @@ func TestMakeInterface(t *testing.T) {
}
*/
func TestCvtCType(t *testing.T) {
test := func(typ types.Type) {
defer func() {
if r := recover(); r == nil {
t.Log("cvtCType: no error?")
}
}()
cvtCType(typ)
}
test(types.NewInterfaceType(nil, nil))
a := types.NewTypeName(0, nil, "a", nil)
sig := types.NewSignatureType(nil, nil, nil, nil, nil, false)
named := types.NewNamed(a, sig, nil)
test(named)
}
func TestCFuncPtr(t *testing.T) {
sig := types.NewSignatureType(nil, nil, nil, nil, nil, false)
csig := (*CFuncPtr)(sig)

View File

@@ -82,7 +82,7 @@ func cvtCType(typ types.Type) (types.Type, bool) {
return cvtCStruct(t)
case *types.Named:
if _, cvt := cvtCType(t.Underlying()); cvt {
panic("todo: named type")
panic("don't define named type")
}
case *types.Signature:
t = CFuncDecl(t)