diff --git a/exercises/simple-linked-list/canonical-data.json b/exercises/simple-linked-list/canonical-data.json new file mode 100644 index 0000000000..f06714aa61 --- /dev/null +++ b/exercises/simple-linked-list/canonical-data.json @@ -0,0 +1,628 @@ +{ + "exercise": "simple-linked-list", + "comments": [ + "Encoding tests and operations using the same field is necessary to have ", + "tests that don't just initialize the list, and then have one operation. ", + "", + "The linked list implements a LIFO. A pop retrieves the last-in value. ", + "As such, the toList operation can be thought as being build using pops, ", + "which means list([1, 2, 3]).toList() would return [3, 2, 1]. ", + "Conversely, the toList is more intuitive to some if it returns data matching how the list was build, ", + "so list([1, 2, 3]).toList() would return [1, 2, 3].", + "", + "To preserve both options, this data has two test groups: toList LIFO and toList FIFO.", + "The tests in these groups are mutually exclusive.", + "", + "When implementing this exercise, select whichever feels more idiomatic for the track." + ], + "cases": [ + { + "description": "count", + "cases": [ + { + "uuid": "962d998c-c203-41e2-8fbd-85a7b98b79b9", + "description": "Empty list has length of zero", + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "count", + "expected": 0 + } + ] + }, + "expected": {} + }, + { + "uuid": "9760262e-d7e4-4639-9840-87e2e2fbb115", + "description": "Singleton list has length of one", + "property": "list", + "input": { + "initialValues": [1], + "operations": [ + { + "operation": "count", + "expected": 1 + } + ] + }, + "expected": {} + }, + { + "uuid": "d9955c90-637c-441b-b41d-8cfb48e924a8", + "description": "Non-empty list has correct length", + "property": "list", + "input": { + "initialValues": [1, 2, 3], + "operations": [ + { + "operation": "count", + "expected": 3 + } + ] + }, + "expected": {} + } + ] + }, + { + "description": "pop", + "cases": [ + { + "uuid": "0c3966db-58f9-4632-b94c-8ea13e54c2c8", + "description": "Pop from empty list is an error", + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "pop", + "expected": { + "error": "list is empty" + } + } + ] + }, + "expected": {} + }, + { + "uuid": "a4f9d2e1-7425-49ef-9ee8-6c0cb3407cf0", + "description": "Can pop from singleton list", + "property": "list", + "input": { + "initialValues": [1], + "operations": [ + { + "operation": "pop", + "expected": 1 + } + ] + }, + "expected": {} + }, + { + "uuid": "6dcbb2c9-d98a-47bc-a010-9c19703d3ea2", + "description": "Can pop from non-empty list", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "pop", + "expected": 2 + } + ] + }, + "expected": {} + }, + { + "uuid": "e83aade9-f030-4096-aaf0-f9dc6491e6cf", + "description": "Can pop multiple items", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "pop", + "expected": 2 + }, + { + "operation": "pop", + "expected": 1 + } + ] + }, + "expected": {} + }, + { + "uuid": "5c46bcf2-c0a9-4654-ae17-f3192436fcf1", + "description": "Pop updates the count", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "count", + "expected": 2 + }, + { + "operation": "pop", + "expected": 2 + }, + { + "operation": "count", + "expected": 1 + }, + { + "operation": "pop", + "expected": 1 + }, + { + "operation": "count", + "expected": 0 + } + ] + }, + "expected": {} + } + ] + }, + { + "description": "push", + "cases": [ + { + "uuid": "70d747a1-2e84-4ebc-bc3f-dcbee6a05f6b", + "description": "Can push to an empty list", + "property": "list", + "input": { + "operations": [ + { + "operation": "push", + "value": 1 + } + ] + }, + "expected": {} + }, + { + "uuid": "391e332e-1f91-4033-b1e0-0e0c17812fa7", + "description": "Can push to a non-empty list", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "push", + "value": 3 + } + ] + }, + "expected": {} + }, + { + "uuid": "ed4b0e01-3bbd-4895-af25-152b5914b3da", + "description": "Push updates count", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "push", + "value": 3 + }, + { + "operation": "count", + "expected": 3 + } + ] + }, + "expected": {} + }, + { + "uuid": "41666790-b932-4e5a-b323-e848a83d12d5", + "description": "Push and pop", + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "push", + "value": 1 + }, + { + "operation": "push", + "value": 2 + }, + { + "operation": "pop", + "expected": 2 + }, + { + "operation": "push", + "value": 3 + }, + { + "operation": "count", + "expected": 2 + }, + { + "operation": "pop", + "expected": 3 + }, + { + "operation": "pop", + "expected": 1 + }, + { + "operation": "count", + "expected": 0 + } + ] + }, + "expected": {} + } + ] + }, + { + "description": "peek", + "cases": [ + { + "uuid": "930a4a5c-76f6-47ec-9be3-4e70993173a1", + "description": "Peek on empty list is an error", + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "peek", + "expected": { + "error": "list is empty" + } + } + ] + }, + "expected": {} + }, + { + "uuid": "43255a50-d919-4e81-afce-e4a271eaedbd", + "description": "Can peek on singleton list", + "property": "list", + "input": { + "initialValues": [1], + "operations": [ + { + "operation": "peek", + "expected": 1 + } + ] + }, + "expected": {} + }, + { + "uuid": "48353020-e25d-4621-a854-e35fb1e15fa7", + "description": "Can peek on non-empty list", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "peek", + "expected": 2 + } + ] + }, + "expected": {} + }, + { + "uuid": "96fcead9-a713-46c2-8005-3f246c873851", + "description": "Peek does not change the count", + "property": "list", + "input": { + "initialValues": [1, 2], + "operations": [ + { + "operation": "peek", + "expected": 2 + }, + { + "operation": "count", + "expected": 2 + } + ] + }, + "expected": {} + }, + { + "uuid": "7576ed05-7ff7-4b84-8efb-d34d62c110f5", + "description": "Can peek after a pop and push", + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "push", + "value": 1 + }, + { + "operation": "push", + "value": 2 + }, + { + "operation": "peek", + "expected": 2 + }, + { + "operation": "pop", + "expected": 2 + }, + { + "operation": "peek", + "expected": 1 + }, + { + "operation": "push", + "value": 3 + }, + { + "operation": "peek", + "expected": 3 + } + ] + }, + "expected": {} + } + ] + }, + { + "description": "toList LIFO", + "comments": ["These cases are mutually exclusive with toList FIFO"], + "cases": [ + { + "uuid": "b97d00b6-2fab-435d-ae74-3233dcc13698", + "description": "Empty linked list to list is empty", + "comments": ["toList LIFO"], + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "toList", + "expected": [] + } + ] + }, + "expected": {} + }, + { + "uuid": "eedeb95f-b5cf-431d-8ad6-5854ba6b251c", + "description": "To list with multiple values", + "comments": ["toList LIFO"], + "property": "list", + "input": { + "initialValues": [1, 2, 3], + "operations": [ + { + "operation": "toList", + "expected": [3, 2, 1] + } + ] + }, + "expected": {} + }, + { + "uuid": "838678de-eaf3-4c14-b34e-7e35b6d851e8", + "description": "To list after a pop", + "comments": ["toList LIFO"], + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "push", + "value": 1 + }, + { + "operation": "push", + "value": 2 + }, + { + "operation": "push", + "value": 3 + }, + { + "operation": "pop", + "expected": 3 + }, + { + "operation": "push", + "value": 4 + }, + { + "operation": "toList", + "expected": [4, 2, 1] + } + ] + }, + "expected": {} + } + ] + }, + { + "description": "toList FIFO", + "comments": ["These cases are mutually exclusive with toList LIFO"], + "cases": [ + { + "uuid": "03fc83a5-48a8-470b-a2d2-a286c5e8365f", + "description": "Empty linked list to list is empty", + "comments": ["toList FIFO"], + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "toList", + "expected": [] + } + ] + }, + "expected": {} + }, + { + "uuid": "1282484e-a58c-426a-972e-90746bda61fc", + "description": "To list with multiple values", + "comments": ["toList FIFO"], + "property": "list", + "input": { + "initialValues": [1, 2, 3], + "operations": [ + { + "operation": "toList", + "expected": [1, 2, 3] + } + ] + }, + "expected": {} + }, + { + "uuid": "05ca3109-1249-4c0c-a567-a3b2f8352a7c", + "description": "To list after a pop", + "comments": ["toList FIFO"], + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "push", + "value": 1 + }, + { + "operation": "push", + "value": 2 + }, + { + "operation": "push", + "value": 3 + }, + { + "operation": "pop", + "expected": 3 + }, + { + "operation": "push", + "value": 4 + }, + { + "operation": "toList", + "expected": [1, 2, 4] + } + ] + }, + "expected": {} + } + ] + }, + { + "description": "reverse", + "cases": [ + { + "uuid": "5e6c1a3d-e34b-46d3-be59-3f132a820ed5", + "description": "Reversed empty list has same values", + "property": "list", + "input": { + "initialValues": [], + "operations": [ + { + "operation": "reverse" + }, + { + "operation": "toList", + "expected": [] + } + ] + }, + "expected": {} + }, + { + "uuid": "93c87ed3-862a-474f-820b-ba3fd6b6daf6", + "description": "Reversed singleton list is same list", + "property": "list", + "input": { + "initialValues": [1], + "operations": [ + { + "operation": "reverse" + }, + { + "operation": "toList", + "expected": [1] + } + ] + }, + "expected": {} + }, + { + "uuid": "92851ebe-9f52-4406-b92e-0718c441a2ab", + "description": "Reversed non-empty list is reversed", + "comments": [ + "This test does not use toList as toList can be implemented different ways." + ], + "property": "list", + "input": { + "initialValues": [1, 2, 3], + "operations": [ + { + "operation": "reverse" + }, + { + "operation": "pop", + "expected": 1 + }, + { + "operation": "pop", + "expected": 2 + }, + { + "operation": "pop", + "expected": 3 + } + ] + }, + "expected": {} + }, + { + "uuid": "9b53af96-7494-4cfa-9b77-b7366fed5c4c", + "description": "Double reverse", + "comments": [ + "This test does not use toList as toList can be implemented different ways." + ], + "property": "list", + "input": { + "initialValues": [1, 2, 3], + "operations": [ + { + "operation": "reverse" + }, + { + "operation": "reverse" + }, + { + "operation": "pop", + "expected": 3 + }, + { + "operation": "pop", + "expected": 2 + }, + { + "operation": "pop", + "expected": 1 + } + ] + }, + "expected": {} + } + ] + } + ] +}