<- Back to shtanton's homepage
aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2024-05-02 21:45:45 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2024-05-02 21:45:45 +0100
commitb434fe4e14f6dcc8d1d7433a29351b8e8ea77d37 (patch)
tree50b7e54713d23c965f6ffc23d9feeecd1dd60301 /main
parent22ccb0c370cf2690f1b1a80fe003e05c6ba5e5ed (diff)
downloadstred-go-main.tar
Add , subex syntax to make FullMerge commands easierHEADmain
Diffstat (limited to 'main')
-rw-r--r--main/main_test.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/main/main_test.go b/main/main_test.go
index 3d10c48..076693d 100644
--- a/main/main_test.go
+++ b/main/main_test.go
@@ -6,7 +6,8 @@ import (
)
const miscInput string = `{"something":{"nested":"Here is my test value"},"array":["Hello","world","these","are","values"],"people":[{"first_name":"Charlie","last_name":"Johnson","age":22},{"first_name":"Tom","last_name":"Johnson","age":18},{"first_name":"Charlie","last_name":"Chaplin","age":122},{"first_name":"John","last_name":"Johnson","age":48}]}`
-const mixedArray string = `{"array":["first",{"name":"second"},"third"]}`
+const mixedArray string = `{"array":["first",null,3,{"name":"second"},"third"]}`
+const mixedArray2 string = `{"array":["first",null,3,"second",{"name":"third"}]}`
func TestSpecificCases(t *testing.T) {
type test struct {
@@ -116,7 +117,7 @@ func TestSpecificCases(t *testing.T) {
},
{
name: "Drop last element of array",
- program: `M/#( "people" @( . #()# )@ )#/{ Ed }`,
+ program: `M/#( "people" @( . , )@ )#/{ Ed }`,
input: miscInput,
expected: `{"something":{"nested":"Here is my test value"},"array":["Hello","world","these","are","values"],"people":[{"first_name":"Charlie","last_name":"Johnson","age":22},{"first_name":"Tom","last_name":"Johnson","age":18},{"first_name":"Charlie","last_name":"Chaplin","age":122}]}`,
},
@@ -128,9 +129,15 @@ func TestSpecificCases(t *testing.T) {
},
{
name: "Drop last element of mixed array",
- program: `M/#( "array" @( . (~[.]~|@()@|#()#) )@ )#/{ Ed }`,
+ program: `M/#( "array" @( . , )@ )#/{ Ed }`,
input: mixedArray,
- expected: `{"array":["first",{"name":"second"}]}`,
+ expected: `{"array":["first",null,3,{"name":"second"}]}`,
+ },
+ {
+ name: "Drop last element of mixed array 2",
+ program: `M/#( "array" @( . , )@ )#/{ Ed }`,
+ input: mixedArray2,
+ expected: `{"array":["first",null,3,"second"]}`,
},
{
name: "Prepend to array",