json-patch/json-patch-tests

should test parent/child copy/move operations

bbarry opened this issue · 0 comments

What should happen when an element is copied/moved to its own ancestor/descendant?

    { "doc": [],
      "patch": [{"op": "copy", "from": "/", "path": "/-"}],
      "expected": [[]],
      "comment": "copy should work when path is compatible descendant of from"},
    { "doc": [[1]],
      "patch": [{"op": "copy", "from": "/0/0", "path": "/-"}],
      "expected": [[1],1],
      "comment": "copy should work when from is compatible descendant of path"},
    { "doc": [[1]],
      "patch": [{"op": "move", "from": "/0/0", "path": "/-"}],
      "expected": [1],
      "comment": "move should work when from is compatible descendant of path"},
    { "doc": {"foo": {}},
      "patch": [{"op": "copy", "from": "/foo", "path": "/foo/bar"}],
      "expected": {"foo": {"bar": {}}},
      "comment": "copy should work when path is compatible descendant of from"},
    { "doc": {"foo": {"bar": {"baz": null}}},
      "patch": [{"op": "copy", "from": "/foo/bar", "path": "/foo"}],
      "expected": {"foo": {"bar": {"baz": null}, "baz": null}},
      "comment": "copy should work when from is compatible descendant of path"},
    { "doc": {"foo": {"bar": {"baz": null}}},
      "patch": [{"op": "move", "from": "/foo/bar", "path": "/foo"}],
      "expected": {"foo": {"baz": null}},
      "comment": "move should work when from is compatible descendant of path"},