-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starbind: fix Starlark slice unmarshaling (#3454)
The unmarshaling code for slices wasn't actually setting the destination. This patch fixes it.
- Loading branch information
1 parent
b5c9edc
commit ae67a45
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package starbind | ||
|
||
import ( | ||
"go.starlark.net/starlark" | ||
"testing" | ||
) | ||
|
||
func TestConv(t *testing.T) { | ||
script := ` | ||
# A list global that we'll unmarhsal into a slice. | ||
x = [1,2] | ||
` | ||
globals, err := starlark.ExecFile(&starlark.Thread{}, "test.star", script, nil) | ||
starlarkVal, ok := globals["x"] | ||
if !ok { | ||
t.Fatal("missing global 'x'") | ||
} | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
var x []int | ||
err = unmarshalStarlarkValue(starlarkVal, &x, "x") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(x) != 2 || x[0] != 1 || x[1] != 2 { | ||
t.Fatalf("expected [1 2], got: %v", x) | ||
} | ||
} |