This commit is contained in:
xushiwei
2024-05-04 07:21:07 +08:00
parent 809a400f57
commit 1cff02e4cc
5 changed files with 51 additions and 13 deletions

View File

@@ -17,9 +17,12 @@
package ssa_test
import (
"go/types"
"testing"
"github.com/goplus/llgo/cl/cltest"
"github.com/goplus/llgo/internal/typeutil"
"github.com/goplus/llgo/ssa"
)
func TestFromTestrt(t *testing.T) {
@@ -34,3 +37,17 @@ func TestRuntime(t *testing.T) {
cltest.Pkg(t, "github.com/goplus/llgo/internal/runtime", "../internal/runtime/llgo_autogen.ll")
cltest.Pkg(t, "github.com/goplus/llgo/internal/abi", "../internal/abi/llgo_autogen.ll")
}
func TestMap(t *testing.T) {
var m typeutil.Map
sig := types.NewSignatureType(nil, nil, nil, nil, nil, false)
m.Set(sig, 1)
csig := (*ssa.CFuncPtr)(sig)
m.Set(csig, 2)
if v := m.At(sig); v.(int) != 1 {
t.Fatal("At(sig):", v)
}
if v := m.At(csig); v.(int) != 2 {
t.Fatal("At(csig):", v)
}
}