Functional Weave
Code in Python

todo.merge@1.0.0

vectors.json

10,258 bytes · view raw

[
  {"name": "two empty lists merge to an empty list", "args": [[], []], "expect": []},
  {"name": "into an empty list, the incoming todos arrive in their own manual order", "args": [[], [{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 5}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 2}]], "expect": [{"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}]},
  {"name": "nothing incoming: the current list in manual order, renumbered", "args": [[{"id": "x", "title": "Task x", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 3}, {"id": "y", "title": "Task y", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}], []], "expect": [{"id": "y", "title": "Task y", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "x", "title": "Task x", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}]},
  {"name": "an id in both: the incoming todo wins, in the current one's place", "args": [[{"id": "a", "title": "Old title", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}], [{"id": "a", "title": "New title", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 7}]], "expect": [{"id": "a", "title": "New title", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}]},
  {"name": "new ids are appended after the current todos", "args": [[{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}], [{"id": "c", "title": "Task c", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "a", "title": "Task a", "notes": null, "done": true, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": "2026-09-27T18:00:00Z", "order": 1}]], "expect": [{"id": "a", "title": "Task a", "notes": null, "done": true, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": "2026-09-27T18:00:00Z", "order": 0}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}, {"id": "c", "title": "Task c", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 2}]},
  {"name": "equal orders keep their array order", "args": [[{"id": "p", "title": "Task p", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "q", "title": "Task q", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}], []], "expect": [{"id": "p", "title": "Task p", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "q", "title": "Task q", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}]},
  {"name": "a new todo with order 0 still goes after the current ones, and gaps close", "args": [[{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 10}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 20}], [{"id": "c", "title": "Task c", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}]], "expect": [{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "b", "title": "Task b", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}, {"id": "c", "title": "Task c", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 2}]},
  {"name": "a done todo reopened in the file comes back open", "args": [[{"id": "a", "title": "Task a", "notes": null, "done": true, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": "2026-09-27T18:00:00Z", "order": 0}], [{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}]], "expect": [{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}]},
  {"name": "a mixed merge: kept, replaced and new", "args": [[{"id": "m", "title": "Task m", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "n", "title": "Task n", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}, {"id": "o", "title": "Task o", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 2}], [{"id": "z", "title": "Task z", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 5}, {"id": "n", "title": "Renamed", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 9}]], "expect": [{"id": "m", "title": "Task m", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "n", "title": "Renamed", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}, {"id": "o", "title": "Task o", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 2}, {"id": "z", "title": "Task z", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 3}]},
  {"name": "an id twice in the incoming list is an error", "args": [[], [{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}]], "expectError": "duplicate id \"a\" in the incoming list"},
  {"name": "an id twice in the current list is an error", "args": [[{"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 0}, {"id": "a", "title": "Task a", "notes": null, "done": false, "priority": "none", "due": null, "tags": [], "recurrence": null, "createdAt": "2026-09-01T09:00:00Z", "completedAt": null, "order": 1}], []], "expectError": "duplicate id \"a\" in the current list"}
]