github.com/3JoB/go-json@v0.10.4/internal/encoder/encode_opcode_test.go (about)

     1  package encoder
     2  
     3  import (
     4  	"testing"
     5  	"unsafe"
     6  )
     7  
     8  func TestDumpOpcode(t *testing.T) {
     9  	ctx := TakeRuntimeContext()
    10  	defer ReleaseRuntimeContext(ctx)
    11  	var v any = 1
    12  	header := (*emptyInterface)(unsafe.Pointer(&v))
    13  	typ := header.typ
    14  	typeptr := uintptr(unsafe.Pointer(typ))
    15  	codeSet, err := CompileToGetCodeSet(ctx, typeptr)
    16  	if err != nil {
    17  		t.Fatal(err)
    18  	}
    19  	codeSet.EscapeKeyCode.Dump()
    20  }