{ "exercise": "triangle", "version": "1.0.0", "comments": [ " Pursuant to discussion in #202, we have decided NOT to test triangles ", " where all side lengths are positive but a + b = c. e.g: ", " (2, 4, 2, Isosceles), (1, 3, 4, Scalene). ", " It's true that the triangle inequality admits such triangles.These ", " triangles have zero area, however. ", " They're degenerate triangles with all three vertices collinear. ", " (In contrast, we will test (0, 0, 0, Illegal), as it is a point) ", " The tests assert properities of the triangle are true or false. ", " See: https://github.com/exercism/x-common/issues/379 for disscussion ", " of this approach ", " How you handle invalid triangles is up to you. These tests suggest a ", " triangle is returned, but all of its properties are false. But you ", " could also have the creation of an invalid triangle return an error ", " or exception. Choose what is idiomatic for your language. " ], "cases": [ { "description": "returns true if the triangle is equilateral", "cases": [ { "description": "true if all sides are equal", "property": "equilateral", "sides": [2, 2, 2], "expected": true }, { "description": "false if any side is unequal", "property": "equilateral", "sides": [2, 3, 2], "expected": false }, { "description": "false if no sides are equal", "property": "equilateral", "sides": [5, 4, 6], "expected": false }, { "description": "All zero sides are illegal, so the triangle is not equilateral", "property": "equilateral", "sides": [0, 0, 0], "expected": false }, { "comments": [ " Your track may choose to skip this test ", " and deal only with integers if appropriate " ], "description": "sides may be floats", "property": "equilateral", "sides": [0.5, 0.5, 0.5], "expected": true } ] }, { "description": "returns true if the triangle is isosceles", "cases": [ { "description": "true if last two sides are equal", "property": "isosceles", "sides": [3, 4, 4], "expected": true }, { "description": "true if first two sides are equal", "property": "isosceles", "sides": [4, 4, 3], "expected": true }, { "description": "true if first and last sides are equal", "property": "isosceles", "sides": [4, 3, 4], "expected": true }, { "description": "equilateral triangles are also isosceles", "property": "isosceles", "sides": [4, 4, 4], "expected": true }, { "description": "false if no sides are equal", "property": "isosceles", "sides": [2, 3, 4], "expected": false }, { "description": "Sides that violate triangle inequality are not isosceles, even if two are equal", "property": "isosceles", "sides": [1, 1, 3], "expected": false }, { "comments": [ " Your track may choose to skip this test ", " and deal only with integers if appropriate " ], "property": "isosceles", "description": "sides may be floats", "sides": [0.5, 0.4, 0.5], "expected": true } ] }, { "description": "returns true if the triangle is scalene", "cases": [ { "description": "true if no sides are equal", "property": "scalene", "sides": [5, 4, 6], "expected": true }, { "description": "false if all sides are equal", "property": "scalene", "sides": [4, 4, 4], "expected": false }, { "description": "false if two sides are equal", "property": "scalene", "sides": [4, 4, 3], "expected": false }, { "description": "Sides that violate triangle inequality are not scalene, even if they are all different", "property": "scalene", "sides": [7, 3, 2], "expected": false }, { "comments": [ " Your track may choose to skip this test ", " and deal only with integers if appropriate " ], "description": "sides may be floats", "property": "scalene", "sides": [0.5, 0.4, 0.6], "expected": true } ] } ] }