From bac9381d071caf437b68c1b4cd08ad9841b9ecf7 Mon Sep 17 00:00:00 2001 From: Michael Morehouse <640167+yawpitch@users.noreply.github.com> Date: Fri, 29 Mar 2019 10:01:33 +0000 Subject: [PATCH] darts: add tests to disallow absolute addition (#1488) * darts: add tests to disallow absolute addition The current tests allow an erroneous-but-passing solution where the sum of the absolute values of the coordinates of the dart are compared to the radius thresholds (ie return 5 if `abs(x) + abs(y)` is greater than 1 but less than or equal to 5), rather than the calculated distance of the dart from the origin. Thanks to grwkremilek for the find. --- exercises/darts/canonical-data.json | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/exercises/darts/canonical-data.json b/exercises/darts/canonical-data.json index 6c9bce93c6..0da1ab8875 100644 --- a/exercises/darts/canonical-data.json +++ b/exercises/darts/canonical-data.json @@ -1,6 +1,6 @@ { "exercise": "darts", - "version": "1.1.0", + "version": "1.2.0", "cases": [ { "description": "Return the correct amount earned by a dart landing in a given point in the target problem.", @@ -67,6 +67,33 @@ "y": -0.1 }, "expected": 10 + }, + { + "property": "score", + "description": "A dart whose coordinates sum to > 1 but whose radius to origin is <= 1 is scored in the inner circle", + "input": { + "x": 0.4, + "y": 0.8 + }, + "expected": 10 + }, + { + "property": "score", + "description": "A dart whose coordinates sum to > 5 but whose radius to origin is <= 5 is scored in the middle circle", + "input": { + "x": 2, + "y": 4 + }, + "expected": 5 + }, + { + "property": "score", + "description": "A dart whose coordinates sum to > 10 but whose radius to origin is <= 10 is scored in the outer circle", + "input": { + "x": 4, + "y": 8 + }, + "expected": 1 } ] }