diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2024-03-30 15:20:07 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2024-03-30 15:20:07 +0000 |
commit | 7a9f00b9bd39173494ea734b899a9f099dafb306 (patch) | |
tree | a169451bcba8c424ade1ff5cdac29eef6818d8d8 /subex/main_test.go | |
parent | 9d82785f46949151b783d83648b39ce9ba40c615 (diff) | |
download | stred-go-7a9f00b9bd39173494ea734b899a9f099dafb306.tar |
Add array value destructure
Diffstat (limited to 'subex/main_test.go')
-rw-r--r-- | subex/main_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
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 { |