| 1 | { |
| 2 | "tests": [ |
| 3 | { |
| 4 | "name": "space between function name and parenthesis", |
| 5 | "selector" : "$[?count (@.*)==1]", |
| 6 | "invalid_selector": true |
| 7 | }, |
| 8 | { |
| 9 | "name": "newline between function name and parenthesis", |
| 10 | "selector" : "$[?count\n(@.*)==1]", |
| 11 | "invalid_selector": true |
| 12 | }, |
| 13 | { |
| 14 | "name": "tab between function name and parenthesis", |
| 15 | "selector" : "$[?count\t(@.*)==1]", |
| 16 | "invalid_selector": true |
| 17 | }, |
| 18 | { |
| 19 | "name": "return between function name and parenthesis", |
| 20 | "selector" : "$[?count\r(@.*)==1]", |
| 21 | "invalid_selector": true |
| 22 | }, |
| 23 | { |
| 24 | "name": "space between parenthesis and arg", |
| 25 | "selector" : "$[?count( @.*)==1]", |
| 26 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 27 | "result": [ {"a": 1}, {"b": 2} ] |
| 28 | }, |
| 29 | { |
| 30 | "name": "newline between parenthesis and arg", |
| 31 | "selector" : "$[?count(\n@.*)==1]", |
| 32 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 33 | "result": [ {"a": 1}, {"b": 2} ] |
| 34 | }, |
| 35 | { |
| 36 | "name": "tab between parenthesis and arg", |
| 37 | "selector" : "$[?count(\t@.*)==1]", |
| 38 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 39 | "result": [ {"a": 1}, {"b": 2} ] |
| 40 | }, |
| 41 | { |
| 42 | "name": "return between parenthesis and arg", |
| 43 | "selector" : "$[?count(\r@.*)==1]", |
| 44 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 45 | "result": [ {"a": 1}, {"b": 2} ] |
| 46 | }, |
| 47 | { |
| 48 | "name": "space between arg and comma", |
| 49 | "selector" : "$[?search(@ ,'[a-z]+')]", |
| 50 | "document" : [ "foo", "123" ], |
| 51 | "result": [ "foo" ] |
| 52 | }, |
| 53 | { |
| 54 | "name": "newline between arg and comma", |
| 55 | "selector" : "$[?search(@\n,'[a-z]+')]", |
| 56 | "document" : [ "foo", "123" ], |
| 57 | "result": [ "foo" ] |
| 58 | }, |
| 59 | { |
| 60 | "name": "tab between arg and comma", |
| 61 | "selector" : "$[?search(@\t,'[a-z]+')]", |
| 62 | "document" : [ "foo", "123" ], |
| 63 | "result": [ "foo" ] |
| 64 | }, |
| 65 | { |
| 66 | "name": "return between arg and comma", |
| 67 | "selector" : "$[?search(@\r,'[a-z]+')]", |
| 68 | "document" : [ "foo", "123" ], |
| 69 | "result": [ "foo" ] |
| 70 | }, |
| 71 | { |
| 72 | "name": "space between comma and arg", |
| 73 | "selector" : "$[?search(@, '[a-z]+')]", |
| 74 | "document" : [ "foo", "123" ], |
| 75 | "result": [ "foo" ] |
| 76 | }, |
| 77 | { |
| 78 | "name": "newline between comma and arg", |
| 79 | "selector" : "$[?search(@,\n'[a-z]+')]", |
| 80 | "document" : [ "foo", "123" ], |
| 81 | "result": [ "foo" ] |
| 82 | }, |
| 83 | { |
| 84 | "name": "tab between comma and arg", |
| 85 | "selector" : "$[?search(@,\t'[a-z]+')]", |
| 86 | "document" : [ "foo", "123" ], |
| 87 | "result": [ "foo" ] |
| 88 | }, |
| 89 | { |
| 90 | "name": "return between comma and arg", |
| 91 | "selector" : "$[?search(@,\r'[a-z]+')]", |
| 92 | "document" : [ "foo", "123" ], |
| 93 | "result": [ "foo" ] |
| 94 | }, |
| 95 | { |
| 96 | "name": "space between arg and parenthesis", |
| 97 | "selector" : "$[?count(@.* )==1]", |
| 98 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 99 | "result": [ {"a": 1}, {"b": 2} ] |
| 100 | }, |
| 101 | { |
| 102 | "name": "newline between arg and parenthesis", |
| 103 | "selector" : "$[?count(@.*\n)==1]", |
| 104 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 105 | "result": [ {"a": 1}, {"b": 2} ] |
| 106 | }, |
| 107 | { |
| 108 | "name": "tab between arg and parenthesis", |
| 109 | "selector" : "$[?count(@.*\t)==1]", |
| 110 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 111 | "result": [ {"a": 1}, {"b": 2} ] |
| 112 | }, |
| 113 | { |
| 114 | "name": "return between arg and parenthesis", |
| 115 | "selector" : "$[?count(@.*\r)==1]", |
| 116 | "document" : [ {"a": 1}, {"b": 2}, {"a": 2, "b": 1} ], |
| 117 | "result": [ {"a": 1}, {"b": 2} ] |
| 118 | }, |
| 119 | { |
| 120 | "name": "spaces in a relative singular selector", |
| 121 | "selector" : "$[?length(@ .a .b) == 3]", |
| 122 | "document" : [ {"a": {"b": "foo"}}, {} ], |
| 123 | "result": [ {"a": {"b": "foo"}} ] |
| 124 | }, |
| 125 | { |
| 126 | "name": "newlines in a relative singular selector", |
| 127 | "selector" : "$[?length(@\n.a\n.b) == 3]", |
| 128 | "document" : [ {"a": {"b": "foo"}}, {} ], |
| 129 | "result": [ {"a": {"b": "foo"}} ] |
| 130 | }, |
| 131 | { |
| 132 | "name": "tabs in a relative singular selector", |
| 133 | "selector" : "$[?length(@\t.a\t.b) == 3]", |
| 134 | "document" : [ {"a": {"b": "foo"}}, {} ], |
| 135 | "result": [ {"a": {"b": "foo"}} ] |
| 136 | }, |
| 137 | { |
| 138 | "name": "returns in a relative singular selector", |
| 139 | "selector" : "$[?length(@\r.a\r.b) == 3]", |
| 140 | "document" : [ {"a": {"b": "foo"}}, {} ], |
| 141 | "result": [ {"a": {"b": "foo"}} ] |
| 142 | }, |
| 143 | { |
| 144 | "name": "spaces in an absolute singular selector", |
| 145 | "selector" : "$..[?length(@)==length($ [0] .a)]", |
| 146 | "document" : [ {"a": "foo"}, {} ], |
| 147 | "result": [ "foo" ] |
| 148 | }, |
| 149 | { |
| 150 | "name": "newlines in an absolute singular selector", |
| 151 | "selector" : "$..[?length(@)==length($\n[0]\n.a)]", |
| 152 | "document" : [ {"a": "foo"}, {} ], |
| 153 | "result": [ "foo" ] |
| 154 | }, |
| 155 | { |
| 156 | "name": "tabs in an absolute singular selector", |
| 157 | "selector" : "$..[?length(@)==length($\t[0]\t.a)]", |
| 158 | "document" : [ {"a": "foo"}, {} ], |
| 159 | "result": [ "foo" ] |
| 160 | }, |
| 161 | { |
| 162 | "name": "returns in an absolute singular selector", |
| 163 | "selector" : "$..[?length(@)==length($\r[0]\r.a)]", |
| 164 | "document" : [ {"a": "foo"}, {} ], |
| 165 | "result": [ "foo" ] |
| 166 | } |
| 167 | ] |
| 168 | } |