github.com/cnboonhan/delve@v0.0.0-20230908061759-363f2388c2fb/pkg/terminal/starbind/conv_test.go (about) 1 package starbind 2 3 import ( 4 "go.starlark.net/starlark" 5 "testing" 6 ) 7 8 func TestConv(t *testing.T) { 9 script := ` 10 # A list global that we'll unmarshal into a slice. 11 x = [1,2] 12 ` 13 globals, err := starlark.ExecFile(&starlark.Thread{}, "test.star", script, nil) 14 starlarkVal, ok := globals["x"] 15 if !ok { 16 t.Fatal("missing global 'x'") 17 } 18 if err != nil { 19 t.Fatal(err) 20 } 21 var x []int 22 err = unmarshalStarlarkValue(starlarkVal, &x, "x") 23 if err != nil { 24 t.Fatal(err) 25 } 26 if len(x) != 2 || x[0] != 1 || x[1] != 2 { 27 t.Fatalf("expected [1 2], got: %v", x) 28 } 29 }