@@ -516,6 +516,8 @@ function testSelectElementByNumericalConditionalExpression() returns error? {
516
516
JsonPathRawTemplate condition7 = ` $[?(@.a2 > 1.1)]` ;
517
517
JsonPathRawTemplate condition8 = ` $[?(@.a1 == 2.34)]` ;
518
518
JsonPathRawTemplate condition9 = ` $[?(@.a1 == 12.34)]` ;
519
+ JsonPathRawTemplate condition10 = ` $[?(@.a1 != 12.34)]` ;
520
+ JsonPathRawTemplate condition11 = ` $[?(@.a1 <= ${d1 } && @.a1 > ${i1 })]` ;
519
521
520
522
json result = check read ([decimalJson , floatJson , intJson ], condition1 );
521
523
test : assertTrue (result is json []);
@@ -552,6 +554,14 @@ function testSelectElementByNumericalConditionalExpression() returns error? {
552
554
result = check read ([decimalJson , floatJson , intJson ], condition9 );
553
555
test : assertTrue (result is json []);
554
556
test : assertEquals (result , < json []> []);
557
+
558
+ result = check read ([decimalJson , floatJson , intJson ], condition10 );
559
+ test : assertTrue (result is json []);
560
+ test : assertEquals (result , [decimalJson , floatJson , intJson ]);
561
+
562
+ result = check read ([decimalJson , floatJson , intJson ], condition11 );
563
+ test : assertTrue (result is json []);
564
+ test : assertEquals (result , < json []> [decimalJson , floatJson ]);
555
565
}
556
566
557
567
@test :Config {}
@@ -638,22 +648,6 @@ function testSelectElementByPatternMatchingExpression() returns error? {
638
648
test : assertEquals (result , {" a1" : 2.34 , " a2" : 3.65 });
639
649
}
640
650
641
- @test :Config {}
642
- function testA() returns error ? {
643
-
644
- json result = check read (j4 , ` $.a2[1][?(@.a2 in ['string', 'string2'])]` );
645
- test : assertEquals (result , < json []> [stringJson ]);
646
-
647
- result = check read (j4 , ` $.a2[1][?(@.a2 nin ['string', 'string2'])]` );
648
- test : assertEquals (result , < json []> []);
649
-
650
- result = check read (j4 , ` $.a2[1][?(@.a1 nin ['string', 'string2'])]` );
651
- test : assertEquals (result , < json []> [stringJson ]);
652
-
653
- result = check read (j4 , ` $.a2[1][?(@.a1 in ['string', 'string2'])]` );
654
- test : assertEquals (result , < json []> []);
655
- }
656
-
657
651
@test :Config {}
658
652
function testFunctionExpression() returns error ? {
659
653
json result = check read (j4 , ` $..a1.sum()` );
@@ -716,3 +710,28 @@ function testFunctionExpression() returns error? {
716
710
result = check read (decimalJson , ` $['a1'].keys()` );
717
711
test : assertEquals (result , ());
718
712
}
713
+
714
+ @test :Config {}
715
+ function testListOperations() returns error ? {
716
+
717
+ json result = check read (j4 , ` $.a2[1][?(@.a2 in ['string', 'string2'])]` );
718
+ test : assertEquals (result , < json []> [stringJson ]);
719
+
720
+ result = check read (j4 , ` $.a2[1][?(@.a2 nin ['string', 'string2'])]` );
721
+ test : assertEquals (result , < json []> []);
722
+
723
+ result = check read (j4 , ` $.a2[1][?(@.a1 nin ['string', 'string2'])]` );
724
+ test : assertEquals (result , < json []> [stringJson ]);
725
+
726
+ result = check read (j4 , ` $.a2[1][?(@.a1 in ['string', 'string2'])]` );
727
+ test : assertEquals (result , < json []> []);
728
+ }
729
+
730
+ @test :Config {}
731
+ function testGeneralJsonPathExpresions() returns error ? {
732
+ json result = check read (j5 , ` $` );
733
+ test : assertEquals (result , j5 );
734
+
735
+ result = check read (j5 , ` @` );
736
+ test : assertEquals (result , j5 );
737
+ }
0 commit comments