From 7a9f00b9bd39173494ea734b899a9f099dafb306 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Sat, 30 Mar 2024 15:20:07 +0000 Subject: Add array value destructure --- subex/main_test.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'subex/main_test.go') diff --git a/subex/main_test.go b/subex/main_test.go index d7424b3..673b807 100644 --- a/subex/main_test.go +++ b/subex/main_test.go @@ -235,6 +235,64 @@ func TestSubexMain(t *testing.T) { walk.StringValue("abcdefghijklm"), }, }, + { + subex: ":(.)-", + input: []walk.Value { + walk.ArrayValue { + { + Index: 0, + Value: walk.NullValue{}, + }, + }, + }, + expected: []walk.Value { + walk.NullValue{}, + }, + }, + { + subex: ":(.{-0}+)-", + input: []walk.Value { + walk.ArrayValue { + { + Index: 0, + Value: walk.NumberValue(4), + }, + { + Index: 1, + Value: walk.NumberValue(-123), + }, + { + Index: 2, + Value: walk.NumberValue(124), + }, + }, + }, + expected: []walk.Value { + walk.NumberValue(5), + }, + }, + { + subex: "~(-(.)~{-0}):", + input: []walk.Value { + walk.StringValue("abc"), + }, + expected: []walk.Value { + walk.ArrayValue { + { + Index: 0, + Value: walk.StringValue("a"), + }, + { + Index: 0, + Value: walk.StringValue("b"), + }, + { + Index: 0, + Value: walk.StringValue("c"), + }, + }, + }, + }, } for i, test := range tests { -- cgit v1.2.3