From b434fe4e14f6dcc8d1d7433a29351b8e8ea77d37 Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Thu, 2 May 2024 21:45:45 +0100 Subject: Add , subex syntax to make FullMerge commands easier --- main/main_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'main') 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", -- cgit v1.2.3