aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/azalea/evaluate_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-05-21 22:47:41 +0900
committerOphestra <cat@gensokyo.uk>2026-05-21 22:47:41 +0900
commitcdd31dd27b79bf997b73325cf31e8bba66a81117 (patch)
tree829b2bc9a022d5a12dbb6bb572b329e5c101391f /internal/rosa/azalea/evaluate_test.go
parent0615899e5666aa3a4c8aa9fb69622be411f33dab (diff)
internal/rosa/azalea: integer arrays
This is useful for some helper functions. Performance is unaffected. Before: BenchmarkStage3-128 8308 1960687 ns/op 1023794 B/op 14755 allocs/op BenchmarkAll-128 3331 5518571 ns/op 2902320 B/op 37993 allocs/op After: BenchmarkStage3-128 8330 1946273 ns/op 1023046 B/op 14750 allocs/op BenchmarkAll-128 3296 5585805 ns/op 2901746 B/op 37991 allocs/op Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/azalea/evaluate_test.go')
-rw-r--r--internal/rosa/azalea/evaluate_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/rosa/azalea/evaluate_test.go b/internal/rosa/azalea/evaluate_test.go
index b4fa4802..7625db62 100644
--- a/internal/rosa/azalea/evaluate_test.go
+++ b/internal/rosa/azalea/evaluate_test.go
@@ -25,6 +25,17 @@ func makeStackCheck(check func(args FArgs) (any, error)) []Frame {
}}}
}
+// checkArgs is like makeStackCheck, but the resulting function asserts that its
+// args match the expected value.
+func checkArgs(want FArgs) []Frame {
+ return makeStackCheck(func(args FArgs) (any, error) {
+ if !reflect.DeepEqual(args, want) {
+ return nil, fmt.Errorf("%#v, want %#v", args, want)
+ }
+ return "\xfd", nil
+ })
+}
+
func TestEvaluate(t *testing.T) {
t.Parallel()
@@ -164,6 +175,11 @@ func TestEvaluate(t *testing.T) {
{"source handle", `package name { source = name; }`, nil, FArgs{
{K: unique.Make(Ident("source")), V: Ident("name")},
}, nil},
+
+ {"integer array", `f { v = [ 0 ]; _v = [ 0, 9 ]; }`, checkArgs(FArgs{
+ {K: unique.Make(Ident("v")), V: []int64{0}},
+ {K: unique.Make(Ident("_v")), V: []int64{0, 9}},
+ }), "\xfd", nil},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {