diff --git a/exercises/pov/canonical-data.json b/exercises/pov/canonical-data.json index 98ad17ddc7..9cbe37dc8a 100644 --- a/exercises/pov/canonical-data.json +++ b/exercises/pov/canonical-data.json @@ -1,7 +1,9 @@ { - "from_pov": { - "description": [ - "Reroot a tree so that its root is the specified node.", + "exercise": "pov", + "version": "1.1.0", + "cases": [{ + "description": "Reroot a tree so that its root is the specified node.", + "comments": [ "In this way, the tree is presented from the point of view of the specified node.", "The input trees used here are those in the `trees` section of this file.", "", @@ -17,7 +19,10 @@ "cases": [ { "description": "Results in the same tree if the input tree is a singleton", - "tree": "singleton", + "property": "fromPov", + "tree": { + "label": "x" + }, "from": "x", "expected": { "label": "x" @@ -25,7 +30,18 @@ }, { "description": "Can reroot a tree with a parent and one sibling", - "tree": "simple", + "property": "fromPov", + "tree": { + "label": "parent", + "children": [ + { + "label": "x" + }, + { + "label": "sibling" + } + ] + }, "from": "x", "expected": { "label": "x", @@ -43,7 +59,24 @@ }, { "description": "Can reroot a tree with a parent and many siblings", - "tree": "large_flat", + "property": "fromPov", + "tree": { + "label": "parent", + "children": [ + { + "label": "a" + }, + { + "label": "x" + }, + { + "label": "b" + }, + { + "label": "c" + } + ] + }, "from": "x", "expected": { "label": "x", @@ -67,7 +100,30 @@ }, { "description": "Can reroot a tree with new root deeply nested in tree", - "tree": "deeply_nested", + "property": "fromPov", + "tree": { + "label": "level-0", + "children": [ + { + "label": "level-1", + "children": [ + { + "label": "level-2", + "children": [ + { + "label": "level-3", + "children": [ + { + "label": "x" + } + ] + } + ] + } + ] + } + ] + }, "from": "x", "expected": { "label": "x", @@ -95,7 +151,23 @@ }, { "description": "Moves children of the new root to same level as former parent", - "tree": "kids", + "property": "fromPov", + "tree": { + "label": "parent", + "children": [ + { + "label": "x", + "children": [ + { + "label": "kid-0" + }, + { + "label": "kid-1" + } + ] + } + ] + }, "from": "x", "expected": { "label": "x", @@ -114,7 +186,45 @@ }, { "description": "Can reroot a complex tree with cousins", - "tree": "cousins", + "property": "fromPov", + "tree": { + "label": "grandparent", + "children": [ + { + "label": "parent", + "children": [ + { + "label": "x", + "children": [ + { + "label": "kid-0" + }, + { + "label": "kid-1" + } + ] + }, + { + "label": "sibling-0" + }, + { + "label": "sibling-1" + } + ] + }, + { + "label": "uncle", + "children": [ + { + "label": "cousin-0" + }, + { + "label": "cousin-1" + } + ] + } + ] + }, "from": "x", "expected": { "label": "x", @@ -157,21 +267,45 @@ }, { "description": "Errors if target does not exist in a singleton tree", - "tree": "singleton", + "property": "fromPov", + "tree": { + "label": "x" + }, "from": "nonexistent", "expected": null }, { "description": "Errors if target does not exist in a large tree", - "tree": "cousins", + "property": "fromPov", + "tree": { + "label": "parent", + "children": [ + { + "label": "x", + "children": [ + { + "label": "kid-0" + }, + { + "label": "kid-1" + } + ] + }, + { + "label": "sibling-0" + }, + { + "label": "sibling-1" + } + ] + }, "from": "nonexistent", "expected": null } ] - }, - "path_to": { - "description": [ - "Given two nodes, find the path between them.", + }, { + "description": "Given two nodes, find the path between them", + "comments": [ "A typical implementation would first reroot the tree on one of the two nodes.", "", "If appropriate for your track, you may test that the input tree is not modified.", @@ -181,9 +315,20 @@ "cases": [ { "description": "Can find path to parent", + "property": "pathTo", "from": "x", "to": "parent", - "tree": "simple", + "tree": { + "label": "parent", + "children": [ + { + "label": "x" + }, + { + "label": "sibling" + } + ] + }, "expected": [ "x", "parent" @@ -191,9 +336,26 @@ }, { "description": "Can find path to sibling", + "property": "pathTo", "from": "x", "to": "b", - "tree": "large_flat", + "tree": { + "label": "parent", + "children": [ + { + "label": "a" + }, + { + "label": "x" + }, + { + "label": "b" + }, + { + "label": "c" + } + ] + }, "expected": [ "x", "parent", @@ -202,9 +364,47 @@ }, { "description": "Can find path to cousin", + "property": "pathTo", "from": "x", "to": "cousin-1", - "tree": "cousins", + "tree": { + "label": "grandparent", + "children": [ + { + "label": "parent", + "children": [ + { + "label": "x", + "children": [ + { + "label": "kid-0" + }, + { + "label": "kid-1" + } + ] + }, + { + "label": "sibling-0" + }, + { + "label": "sibling-1" + } + ] + }, + { + "label": "uncle", + "children": [ + { + "label": "cousin-0" + }, + { + "label": "cousin-1" + } + ] + } + ] + }, "expected": [ "x", "parent", @@ -215,109 +415,67 @@ }, { "description": "Can find path from nodes other than x", - "from": "kid-1", - "to": "cousin-0", - "tree": "cousins", + "property": "pathTo", + "from": "a", + "to": "c", + "tree": { + "label": "parent", + "children": [ + { + "label": "a" + }, + { + "label": "x" + }, + { + "label": "b" + }, + { + "label": "c" + } + ] + }, "expected": [ - "kid-1", - "x", + "a", "parent", - "grandparent", - "uncle", - "cousin-0" + "c" ] }, { "description": "Errors if destination does not exist", + "property": "pathTo", "from": "x", "to": "nonexistent", - "tree": "cousins", - "expected": null - }, - { - "description": "Errors if source does not exist", - "from": "nonexistent", - "to": "x", - "tree": "cousins", - "expected": null - } - ] - }, - "trees": { - "singleton": { - "label": "x" - }, - "simple": { - "label": "parent", - "children": [ - { - "label": "x" - }, - { - "label": "sibling" - } - ] - }, - "large_flat": { - "label": "parent", - "children": [ - { - "label": "a" - }, - { - "label": "x" - }, - { - "label": "b" - }, - { - "label": "c" - } - ] - }, - "deeply_nested": { - "label": "level-0", - "children": [ - { - "label": "level-1", + "tree": { + "label": "parent", "children": [ { - "label": "level-2", + "label": "x", "children": [ { - "label": "level-3", - "children": [ - { - "label": "x" - } - ] + "label": "kid-0" + }, + { + "label": "kid-1" } ] - } - ] - } - ] - }, - "kids": { - "label": "parent", - "children": [ - { - "label": "x", - "children": [ + }, { - "label": "kid-0" + "label": "sibling-0" }, { - "label": "kid-1" + "label": "sibling-1" } ] - } - ] - }, - "cousins": { - "label": "grandparent", - "children": [ - { + }, + "expected": null + }, + { + "description": "Errors if source does not exist", + "property": "pathTo", + "from": "nonexistent", + "to": "x", + "tree": { "label": "parent", "children": [ { @@ -339,18 +497,8 @@ } ] }, - { - "label": "uncle", - "children": [ - { - "label": "cousin-0" - }, - { - "label": "cousin-1" - } - ] - } - ] - } - } + "expected": null + } + ] + }] }