1{
2 "array-index-coercion": [
3 {
4 "expr": "foo[null]",
5 "contexts": {
6 "foo": [
7 "zero",
8 "one",
9 "two"
10 ]
11 },
12 "result": { "kind": "String", "value": "zero" }
13 },
14 {
15 "expr": "foo[false]",
16 "contexts": {
17 "foo": [
18 "zero",
19 "one",
20 "two"
21 ]
22 },
23 "result": { "kind": "String", "value": "zero" }
24 },
25 {
26 "expr": "foo[true]",
27 "contexts": {
28 "foo": [
29 "zero",
30 "one",
31 "two"
32 ]
33 },
34 "result": { "kind": "String", "value": "one" }
35 },
36 {
37 "expr": "foo[' 0.0 ']",
38 "contexts": {
39 "foo": [
40 "zero",
41 "one",
42 "two"
43 ]
44 },
45 "result": { "kind": "String", "value": "zero" }
46 },
47 {
48 "expr": "foo[' 0x02 ']",
49 "contexts": {
50 "foo": [
51 "zero",
52 "one",
53 "two"
54 ]
55 },
56 "result": { "kind": "String", "value": "two" }
57 },
58 {
59 "expr": "foo[' asdf ']",
60 "contexts": {
61 "foo": [
62 "zero",
63 "one",
64 "two"
65 ]
66 },
67 "result": { "kind": "Null", "value": null }
68 },
69 {
70 "expr": "foo[fromjson('[]')]",
71 "contexts": {
72 "foo": [
73 "zero",
74 "one",
75 "two"
76 ]
77 },
78 "result": { "kind": "Null", "value": null }
79 },
80 {
81 "expr": "foo[fromjson('{}')]",
82 "contexts": {
83 "foo": [
84 "zero",
85 "one",
86 "two"
87 ]
88 },
89 "result": { "kind": "Null", "value": null }
90 }
91 ],
92 "array-index-out-of-range": [
93 {
94 "expr": "foo[-1]",
95 "contexts": {
96 "foo": [
97 "zero",
98 "one",
99 "two"
100 ]
101 },
102 "result": { "kind": "Null", "value": null }
103 },
104 {
105 "expr": "foo[3]",
106 "contexts": {
107 "foo": [
108 "zero",
109 "one",
110 "two"
111 ]
112 },
113 "result": { "kind": "Null", "value": null }
114 },
115 {
116 "expr": "foo[-Infinity]",
117 "contexts": {
118 "foo": [
119 "zero",
120 "one",
121 "two"
122 ]
123 },
124 "result": { "kind": "Null", "value": null }
125 },
126 {
127 "expr": "foo[Infinity]",
128 "contexts": {
129 "foo": [
130 "zero",
131 "one",
132 "two"
133 ]
134 },
135 "result": { "kind": "Null", "value": null }
136 },
137 {
138 "expr": "foo[NaN]",
139 "contexts": {
140 "foo": [
141 "zero",
142 "one",
143 "two"
144 ]
145 },
146 "result": { "kind": "Null", "value": null }
147 }
148 ],
149 "object-case-insensitive": [
150 {
151 "expr": "foo['bAr']",
152 "contexts": {
153 "foo": {
154 "BaR": "baz"
155 }
156 },
157 "result": { "kind": "String", "value": "baz" }
158 }
159 ],
160 "object-index-coercion": [
161 {
162 "expr": "foo[5]",
163 "contexts": {
164 "foo": {
165 "5": "it's 5"
166 }
167 },
168 "result": { "kind": "String", "value": "it's 5" }
169 },
170 {
171 "expr": "foo[.5]",
172 "contexts": {
173 "foo": {
174 "0.5": "it's 0.5"
175 }
176 },
177 "result": { "kind": "String", "value": "it's 0.5" }
178 },
179 {
180 "expr": "foo[-.5]",
181 "contexts": {
182 "foo": {
183 "-0.5": "it's -0.5"
184 }
185 },
186 "result": { "kind": "String", "value": "it's -0.5" }
187 },
188 {
189 "expr": "foo[0x0f]",
190 "contexts": {
191 "foo": {
192 "15": "it's 15"
193 }
194 },
195 "result": { "kind": "String", "value": "it's 15" }
196 },
197 {
198 "expr": "foo[NaN]",
199 "contexts": {
200 "foo": {
201 "NaN": "it's NaN"
202 }
203 },
204 "result": { "kind": "String", "value": "it's NaN" }
205 },
206 {
207 "expr": "foo[Infinity]",
208 "contexts": {
209 "foo": {
210 "Infinity": "it's Infinity"
211 }
212 },
213 "result": { "kind": "String", "value": "it's Infinity" }
214 },
215 {
216 "expr": "foo[-Infinity]",
217 "contexts": {
218 "foo": {
219 "-Infinity": "it's -Infinity"
220 }
221 },
222 "result": { "kind": "String", "value": "it's -Infinity" }
223 },
224 {
225 "expr": "foo[null]",
226 "contexts": {
227 "foo": {
228 "": "it's null"
229 }
230 },
231 "result": { "kind": "String", "value": "it's null" }
232 },
233 {
234 "expr": "foo[true]",
235 "contexts": {
236 "foo": {
237 "true": "it's true"
238 }
239 },
240 "result": { "kind": "String", "value": "it's true" }
241 },
242 {
243 "expr": "foo[false]",
244 "contexts": {
245 "foo": {
246 "false": "it's false"
247 }
248 },
249 "result": { "kind": "String", "value": "it's false" }
250 },
251 {
252 "expr": "foo[fromJson('{}')]",
253 "contexts": {
254 "foo": {
255 "Object": "It's Object"
256 }
257 },
258 "result": { "kind": "Null", "value": null }
259 },
260 {
261 "expr": "foo[format('{0}', fromJson('{}'))]",
262 "contexts": {
263 "foo": {
264 "Object": "It's Object"
265 }
266 },
267 "result": { "kind": "String", "value": "It's Object" }
268 },
269 {
270 "expr": "foo[fromJson('[]')]",
271 "contexts": {
272 "foo": {
273 "Array": "It's Array"
274 }
275 },
276 "result": { "kind": "Null", "value": null }
277 },
278 {
279 "expr": "foo[format('{0}', fromJson('[]'))]",
280 "contexts": {
281 "foo": {
282 "Array": "It's Array"
283 }
284 },
285 "result": { "kind": "String", "value": "It's Array" }
286 }
287 ],
288 "object-index-out-of-range": [
289 {
290 "expr": "foo['']",
291 "contexts": {
292 "foo": {
293 "bar": "baz"
294 }
295 },
296 "result": { "kind": "Null", "value": null }
297 },
298 {
299 "expr": "foo['asdf']",
300 "contexts": {
301 "foo": {
302 "bar": "baz"
303 }
304 },
305 "result": { "kind": "Null", "value": null }
306 }
307 ],
308 "index-following-function": [
309 {
310 "expr": "fromJson('[\"one\", \"two\"]')[1]",
311 "result": { "kind": "String", "value": "two" }
312 }
313 ],
314 "index-following-group": [
315 {
316 "expr": "(fromJson('[\"one\", \"two\"]'))[1]",
317 "result": { "kind": "String", "value": "two" }
318 }
319 ],
320 "index-star": [
321 {
322 "expr": "foo[*]",
323 "contexts": {
324 "foo": {
325 "one": "one val",
326 "two": "two val",
327 "*": "star val"
328 }
329 },
330 "result": { "kind": "Array", "value": ["one val", "two val", "star val"] }
331 },
332 {
333 "expr": "foo['*']",
334 "contexts": {
335 "foo": {
336 "one": "one val",
337 "two": "two val",
338 "*": "star val"
339 }
340 },
341 "result": { "kind": "String", "value": "star val" }
342 },
343 {
344 "expr": "foo[*]",
345 "contexts": {
346 "foo": [
347 "one",
348 "two"
349 ]
350 },
351 "result": { "kind": "Array", "value": ["one", "two"] }
352 }
353 ]
354}