|
| 1 | +[ |
| 2 | + { |
| 3 | + "description": "$ref to part of the script", |
| 4 | + "data": { "abc": 2 }, |
| 5 | + "tests": [ |
| 6 | + { |
| 7 | + "description": "relative reference to constant", |
| 8 | + "script": { "foo": 1, "bar": { "$ref": "1/foo" } }, |
| 9 | + "result": { "foo": 1, "bar": 1 } |
| 10 | + }, |
| 11 | + { |
| 12 | + "description": "absolute reference to constant", |
| 13 | + "script": { "foo": { "$ref": "/bar" }, "bar": 1 }, |
| 14 | + "result": { "foo": 1, "bar": 1 } |
| 15 | + }, |
| 16 | + { |
| 17 | + "description": "relative reference to script", |
| 18 | + "script": { |
| 19 | + "foo": { "bar": { "$data": "/abc" } }, |
| 20 | + "baz": { "boo": { "$ref": "2/foo/bar" } } |
| 21 | + }, |
| 22 | + "result": { |
| 23 | + "foo": { "bar": 2 }, |
| 24 | + "baz": { "boo": 2 } |
| 25 | + } |
| 26 | + }, |
| 27 | + { |
| 28 | + "description": "absolute reference to script", |
| 29 | + "script": { |
| 30 | + "foo": { "bar": { "$ref": "/baz/boo" } }, |
| 31 | + "baz": { "boo": { "$data": "/abc" } } |
| 32 | + }, |
| 33 | + "result": { |
| 34 | + "foo": { "bar": 2 }, |
| 35 | + "baz": { "boo": 2 } |
| 36 | + } |
| 37 | + }, |
| 38 | + { |
| 39 | + "description": "relative reference to async script", |
| 40 | + "script": { |
| 41 | + "foo": { "bar": { "$delay": { "$data": "/abc" } } }, |
| 42 | + "baz": { "boo": { "$ref": "2/foo/bar" } } |
| 43 | + }, |
| 44 | + "result": { |
| 45 | + "foo": { "bar": 2 }, |
| 46 | + "baz": { "boo": 2 } |
| 47 | + } |
| 48 | + }, |
| 49 | + { |
| 50 | + "description": "absolute reference to async script", |
| 51 | + "script": { |
| 52 | + "foo": { "bar": { "$ref": "/baz/boo" } }, |
| 53 | + "baz": { "boo": { "$delay": { "$data": "/abc" } } } |
| 54 | + }, |
| 55 | + "result": { |
| 56 | + "foo": { "bar": 2 }, |
| 57 | + "baz": { "boo": 2 } |
| 58 | + } |
| 59 | + }, |
| 60 | + { |
| 61 | + "description": "relative reference (less deep) to async script", |
| 62 | + "script": { |
| 63 | + "foo": { "bar": { "$delay": { "$data": "/abc" } } }, |
| 64 | + "baz": { "boo": { "$ref": "2/foo" } } |
| 65 | + }, |
| 66 | + "result": { |
| 67 | + "foo": { "bar": 2 }, |
| 68 | + "baz": { "boo": { "bar": 2 } } |
| 69 | + } |
| 70 | + }, |
| 71 | + { |
| 72 | + "description": "absolute reference (less deep) to async script", |
| 73 | + "script": { |
| 74 | + "foo": { "bar": { "$ref": "/baz" } }, |
| 75 | + "baz": { "boo": { "$delay": { "$data": "/abc" } } } |
| 76 | + }, |
| 77 | + "result": { |
| 78 | + "foo": { "bar": { "boo": 2 } }, |
| 79 | + "baz": { "boo": 2 } |
| 80 | + } |
| 81 | + }, |
| 82 | + { |
| 83 | + "description": "relative reference (more deep) to async script", |
| 84 | + "script": { |
| 85 | + "foo": { "bar": { "$delay": { "$data": "/abc" } } }, |
| 86 | + "baz": { "$ref": "1/foo/bar" } |
| 87 | + }, |
| 88 | + "result": { |
| 89 | + "foo": { "bar": 2 }, |
| 90 | + "baz": 2 |
| 91 | + } |
| 92 | + }, |
| 93 | + { |
| 94 | + "description": "absolute reference (more deep) to async script", |
| 95 | + "script": { |
| 96 | + "foo": { "$ref": "/baz/boo" }, |
| 97 | + "baz": { "boo": { "$delay": { "$data": "/abc" } } } |
| 98 | + }, |
| 99 | + "result": { |
| 100 | + "foo": 2, |
| 101 | + "baz": { "boo": 2 } |
| 102 | + } |
| 103 | + }, |
| 104 | + { |
| 105 | + "description": "relative reference in async script", |
| 106 | + "script": { |
| 107 | + "foo": { "bar": { "$delay": { "$data": "/abc" } } }, |
| 108 | + "baz": { "boo": { "$delay": { "$ref": "2/foo/bar" } } } |
| 109 | + }, |
| 110 | + "result": { |
| 111 | + "foo": { "bar": 2 }, |
| 112 | + "baz": { "boo": 2 } |
| 113 | + } |
| 114 | + }, |
| 115 | + { |
| 116 | + "description": "absolute reference in async script", |
| 117 | + "script": { |
| 118 | + "foo": { "bar": { "$delay": { "$ref": "/baz/boo" } } }, |
| 119 | + "baz": { "boo": { "$delay": { "$data": "/abc" } } } |
| 120 | + }, |
| 121 | + "result": { |
| 122 | + "foo": { "bar": 2 }, |
| 123 | + "baz": { "boo": 2 } |
| 124 | + } |
| 125 | + } |
| 126 | + ] |
| 127 | + }, |
| 128 | + { |
| 129 | + "description": "$ref between array items", |
| 130 | + "tests": [ |
| 131 | + { |
| 132 | + "description": "relative reference to array item", |
| 133 | + "script": { |
| 134 | + "foo": { "$ref": "1/bar/1" }, |
| 135 | + "bar": [ 1, 2 ] |
| 136 | + }, |
| 137 | + "result": { "foo": 2, "bar": [ 1, 2 ] } |
| 138 | + }, |
| 139 | + { |
| 140 | + "skip": true, |
| 141 | + "description": "relative reference to async array item", |
| 142 | + "script": { |
| 143 | + "foo": { "$ref": "1/bar/1" }, |
| 144 | + "bar": [ 1, { "$delay": 2 } ] |
| 145 | + }, |
| 146 | + "result": { "foo": 2, "bar": [ 1, 2 ] } |
| 147 | + }, |
| 148 | + { |
| 149 | + "description": "relative reference to async array item in object", |
| 150 | + "script": { |
| 151 | + "foo": { "$ref": "1/bar/baz/1" }, |
| 152 | + "bar": { |
| 153 | + "baz": [ 1, { "$delay": 2 } ] |
| 154 | + } |
| 155 | + }, |
| 156 | + "result": { |
| 157 | + "foo": 2, |
| 158 | + "bar": { |
| 159 | + "baz": [ 1, 2 ] } |
| 160 | + } |
| 161 | + }, |
| 162 | + { |
| 163 | + "skip": true, |
| 164 | + "description": "absolute reference to async array item", |
| 165 | + "script": { |
| 166 | + "foo": { "$ref": "/bar/1" }, |
| 167 | + "bar": [ 1, { "$delay": 2 } ] |
| 168 | + }, |
| 169 | + "result": { "foo": 2, "bar": [ 1, 2 ] } |
| 170 | + }, |
| 171 | + { |
| 172 | + "description": "absolute reference to async array item in object", |
| 173 | + "script": { |
| 174 | + "foo": { "$ref": "1/bar/baz/1" }, |
| 175 | + "bar": { |
| 176 | + "baz": [ 1, { "$delay": 2 } ] |
| 177 | + } |
| 178 | + }, |
| 179 | + "result": { |
| 180 | + "foo": 2, |
| 181 | + "bar": { |
| 182 | + "baz": [ 1, 2 ] } |
| 183 | + } |
| 184 | + } |
| 185 | + ] |
| 186 | + }, |
| 187 | + { |
| 188 | + "description": "$ref errors", |
| 189 | + "tests": [ |
| 190 | + { |
| 191 | + "description": "relative reference above the root", |
| 192 | + "script": { "foo": 1, "bar": { "$ref": "2/foo" } }, |
| 193 | + "error": true |
| 194 | + }, |
| 195 | + { |
| 196 | + "description": "relative reference to itself", |
| 197 | + "script": { "bar": { "$ref": "0/" } }, |
| 198 | + "error": true |
| 199 | + }, |
| 200 | + { |
| 201 | + "description": "relative reference to itself via parent", |
| 202 | + "script": { "bar": { "$ref": "1/bar" } }, |
| 203 | + "error": true |
| 204 | + }, |
| 205 | + { |
| 206 | + "description": "absolute reference to itself", |
| 207 | + "script": { "bar": { "$ref": "/bar" } }, |
| 208 | + "error": true |
| 209 | + }, |
| 210 | + { |
| 211 | + "description": "relative reference to child", |
| 212 | + "script": { "bar": { "$ref": "0/foo" } }, |
| 213 | + "error": true |
| 214 | + }, |
| 215 | + { |
| 216 | + "description": "relative reference to child via parent", |
| 217 | + "script": { "bar": { "$ref": "1/bar/foo" } }, |
| 218 | + "error": true |
| 219 | + }, |
| 220 | + { |
| 221 | + "description": "absolute reference to child", |
| 222 | + "script": { "bar": { "$ref": "/bar/foo" } }, |
| 223 | + "error": true |
| 224 | + }, |
| 225 | + { |
| 226 | + "skip": true, |
| 227 | + "description": "relative reference to the previous item in array is OK", |
| 228 | + "script": [ 1, { "$ref": "1/0" } ], |
| 229 | + "result": [ 1, 1 ] |
| 230 | + }, |
| 231 | + { |
| 232 | + "description": "relative reference to the next item in array is error", |
| 233 | + "script": [ { "$ref": "1/1" }, 1 ], |
| 234 | + "error": true |
| 235 | + } |
| 236 | + ] |
| 237 | + } |
| 238 | +] |
0 commit comments