|
108 | 108 | "expected": ["bar", "foo", "sil"] }, |
109 | 109 |
|
110 | 110 | { "doc": ["foo", "sil"], |
111 | | - "patch": [{"op":" add", "path": "/2", "value": "bar"}], |
| 111 | + "patch": [{"op":"add", "path": "/2", "value": "bar"}], |
112 | 112 | "expected": ["foo", "sil", "bar"] }, |
113 | 113 |
|
| 114 | + { "comment": "test against implementation-specific numeric parsing", |
| 115 | + "doc": {"1e0": "foo"}, |
| 116 | + "patch": [{"op": "test", "path": "/1e0", "value": "foo"}], |
| 117 | + "expected": {"1e0": "foo"} }, |
| 118 | + |
| 119 | + { "comment": "test with bad number should fail", |
| 120 | + "doc": ["foo", "bar"], |
| 121 | + "patch": [{"op": "test", "path": "/1e0", "value": "bar"}], |
| 122 | + "error": "test op shouldn't get array element 1" }, |
| 123 | + |
114 | 124 | { "doc": ["foo", "sil"], |
115 | 125 | "patch": [{"op": "add", "path": "/bar", "value": 42}], |
116 | 126 | "error": "Object operation on array target" }, |
|
223 | 233 |
|
224 | 234 | { "comment": "Move to same location has no effect", |
225 | 235 | "doc": {"foo": 1}, |
226 | | - "patch": [{"op": "move", "path": "/foo", "to": "/foo"}], |
| 236 | + "patch": [{"op": "move", "from": "/foo", "path": "/foo"}], |
227 | 237 | "expected": {"foo": 1} }, |
228 | 238 |
|
229 | 239 | { "doc": {"foo": 1, "baz": [{"qux": "hello"}]}, |
230 | | - "patch": [{"op": "move", "path": "/foo", "to": "/bar"}], |
| 240 | + "patch": [{"op": "move", "from": "/foo", "path": "/bar"}], |
231 | 241 | "expected": {"baz": [{"qux": "hello"}], "bar": 1} }, |
232 | 242 |
|
233 | 243 | { "doc": {"baz": [{"qux": "hello"}], "bar": 1}, |
234 | | - "patch": [{"op": "move", "path": "/baz/0/qux", "to": "/baz/1"}], |
| 244 | + "patch": [{"op": "move", "from": "/baz/0/qux", "path": "/baz/1"}], |
235 | 245 | "expected": {"baz": [{}, "hello"], "bar": 1} }, |
236 | 246 |
|
237 | 247 | { "doc": {"baz": [{"qux": "hello"}], "bar": 1}, |
238 | | - "patch": [{"op": "copy", "path": "/baz/0", "to": "/boo"}], |
| 248 | + "patch": [{"op": "copy", "from": "/baz/0", "path": "/boo"}], |
239 | 249 | "expected": {"baz":[{"qux":"hello"}],"bar":1,"boo":{"qux":"hello"}} }, |
240 | 250 |
|
| 251 | + { "comment": "replacing the root of the document is possible with add", |
| 252 | + "doc": {"foo": "bar"}, |
| 253 | + "patch": [{"op": "add", "path": "", "value": {"baz": "qux"}}], |
| 254 | + "expected": {"baz":"qux"}}, |
| 255 | + |
| 256 | + { "comment": "Adding to \"/-\" adds to the end of the array", |
| 257 | + "doc": [ 1, 2 ], |
| 258 | + "patch": [ { "op": "add", "path": "/-", "value": { "foo": [ "bar", "baz" ] } } ], |
| 259 | + "expected": [ 1, 2, { "foo": [ "bar", "baz" ] } ]}, |
| 260 | + |
| 261 | + { "comment": "Adding to \"/-\" adds to the end of the array, even n levels down", |
| 262 | + "doc": [ 1, 2, [ 3, [ 4, 5 ] ] ], |
| 263 | + "patch": [ { "op": "add", "path": "/2/1/-", "value": { "foo": [ "bar", "baz" ] } } ], |
| 264 | + "expected": [ 1, 2, [ 3, [ 4, 5, { "foo": [ "bar", "baz" ] } ] ] ]}, |
| 265 | + |
241 | 266 | { "comment": "tests complete" } |
242 | 267 | ] |
0 commit comments