Debian Codegraph @

jsonpath-compliance-test-suite/tests/functions/match.json

raw symbols SCIP
1 {
2 "tests": [
3 {
4 "name": "found match",
5 "selector" : "$[?match(@.a, 'a.*')]",
6 "document" : [{"a": "ab"}],
7 "result": [
8 {"a":"ab"}
9 ]
10 },
11 {
12 "name": "double quotes",
13 "selector" : "$[?match(@.a, \"a.*\")]",
14 "document" : [{"a": "ab"}],
15 "result": [
16 {"a":"ab"}
17 ]
18 },
19 {
20 "name": "regex from the document",
21 "selector" : "$.values[?match(@, $.regex)]",
22 "document" : {"regex": "b.?b", "values": ["abc", "bcd", "bab", "bba", "bbab", "b", true, [], {}]},
23 "result": ["bab"]
24 },
25 {
26 "name": "don't select match",
27 "selector" : "$[?!match(@.a, 'a.*')]",
28 "document" : [{"a": "ab"}],
29 "result": [
30 ]
31 },
32 {
33 "name": "not a match",
34 "selector" : "$[?match(@.a, 'a.*')]",
35 "document" : [{"a": "bc"}],
36 "result": []
37 },
38 {
39 "name": "select non-match",
40 "selector" : "$[?!match(@.a, 'a.*')]",
41 "document" : [{"a": "bc"}],
42 "result": [{"a": "bc"}]
43 },
44 {
45 "name": "non-string first arg",
46 "selector" : "$[?match(1, 'a.*')]",
47 "document" : [{"a": "bc"}],
48 "result": []
49 },
50 {
51 "name": "non-string second arg",
52 "selector" : "$[?match(@.a, 1)]",
53 "document" : [{"a": "bc"}],
54 "result": []
55 },
56 {
57 "name": "filter, match function, unicode char class, uppercase",
58 "selector": "$[?match(@, '\\\\p{Lu}')]",
59 "document": ["ж", "Ж", "1", "жЖ", true, [], {}],
60 "result": ["Ж"]
61 },
62 {
63 "name": "filter, match function, unicode char class negated, uppercase",
64 "selector": "$[?match(@, '\\\\P{Lu}')]",
65 "document": ["ж", "Ж", "1", true, [], {}],
66 "result": ["ж", "1"]
67 },
68 {
69 "name": "filter, match function, unicode, surrogate pair",
70 "selector": "$[?match(@, 'a.b')]",
71 "document": ["a\uD800\uDD01b", "ab", "1", true, [], {}],
72 "result": ["a\uD800\uDD01b"]
73 },
74 {
75 "name": "result cannot be compared",
76 "selector" : "$[?match(@.a, 'a.*')==true]",
77 "invalid_selector": true
78 },
79 {
80 "name": "too few params",
81 "selector" : "$[?match(@.a)==1]",
82 "invalid_selector": true
83 },
84 {
85 "name": "too many params",
86 "selector" : "$[?match(@.a,@.b,@.c)==1]",
87 "invalid_selector": true
88 },
89 {
90 "name": "arg is a function expression",
91 "selector": "$.values[?match(@.a, value($..['regex']))]",
92 "document": {
93 "regex": "a.*",
94 "values": [
95 {
96 "a": "ab"
97 },
98 {
99 "a": "ba"
100 }
101 ]
102 },
103 "result": [
104 {
105 "a": "ab"
106 }
107 ]
108 }
109 ]
110 }