diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2024-03-30 09:42:00 +0000 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2024-03-30 09:42:00 +0000 |
commit | 9d82785f46949151b783d83648b39ce9ba40c615 (patch) | |
tree | 8c766d9799ce331a6d129ad5c2e5e6d6e7b7d69e /subex/main_test.go | |
parent | ad0cde67e01a54a138acf760642d62aedbfece46 (diff) | |
download | stred-go-9d82785f46949151b783d83648b39ce9ba40c615.tar |
Add none structures and allow mismatched destructuring
Diffstat (limited to 'subex/main_test.go')
-rw-r--r-- | subex/main_test.go | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/subex/main_test.go b/subex/main_test.go index 78a62c4..d7424b3 100644 --- a/subex/main_test.go +++ b/subex/main_test.go @@ -61,6 +61,15 @@ func TestSubexMain(t *testing.T) { }, }, { + subex: `~(.)~`, + input: []walk.Value { + walk.StringValue("a"), + }, + expected: []walk.Value { + walk.StringValue("a"), + }, + }, + { subex: `~(.$_(.{-0}))~`, input: []walk.Value { walk.StringValue("hello"), @@ -182,9 +191,54 @@ func TestSubexMain(t *testing.T) { }, }, }, + { + subex: "-(`0`.)@", + input: []walk.Value { + walk.NumberValue(4), + }, + expected: []walk.Value { + walk.ArrayValue { + { + Index: 0, + Value: walk.NumberValue(4), + }, + }, + }, + }, + { + subex: `@(.$_~(.{-0})-{-0})~`, + input: []walk.Value { + walk.ArrayValue { + { + Index: 0, + Value: walk.StringValue("ab"), + }, + { + Index: 1, + Value: walk.StringValue("cd"), + }, + { + Index: 2, + Value: walk.StringValue("efg"), + }, + { + Index: 3, + Value: walk.StringValue(""), + }, + { + Index: 4, + Value: walk.StringValue("hijklm"), + }, + }, + }, + expected: []walk.Value { + walk.StringValue("abcdefghijklm"), + }, + }, } - for _, test := range tests { + for i, test := range tests { + t.Logf("Running test: %d", i) lexer := NewStringRuneReader(test.subex) ast := Parse(lexer) transducer := CompileTransducer(ast) |