Skip to content

Commit 5470fef

Browse files
authored
all-your-base: Be explicit about error cases (#1000)
all-your-base 2.0.0 This uses the error object defined in #401 (comment) and thenceforth added to the README's **Test Data Format**. In #280 we made the explicit choice to leave various cases `expected: null` where tracks can make their own decisions (leading zeroes, the representations of zero, whether empty sequence is acceptable as input). However, since `expected: null` is also used for cases where there is always an error (and there is no decision being left to the tracks), it becomes unreasonably hard to tell cases in these two categories apart. To make this easier, all cases in the latter category (always are errors) can canonically be marked as such.
1 parent b3a735c commit 5470fef

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

exercises/all-your-base/canonical-data.json

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"exercise": "all-your-base",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"comments": [
55
"This canonical data makes the following choices:",
66
"1. Zero is always represented in outputs as [0] instead of [].",
@@ -10,11 +10,6 @@
1010
"",
1111
"Tracks that wish to make different decisions for these choices may translate appropriately.",
1212
"",
13-
"It's up to each track do decide:",
14-
"How should invalid input be handled?",
15-
"",
16-
"All the undefined cases are marked as null.",
17-
"",
1813
"All your numeric-base are belong to [2..]. :)"
1914
],
2015
"cases": [
@@ -120,71 +115,71 @@
120115
"input_base": 1,
121116
"input_digits": [],
122117
"output_base": 10,
123-
"expected": null
118+
"expected": {"error": "input base must be >= 2"}
124119
},
125120
{
126121
"description": "first base is zero",
127122
"property": "rebase",
128123
"input_base": 0,
129124
"input_digits": [],
130125
"output_base": 10,
131-
"expected": null
126+
"expected": {"error": "input base must be >= 2"}
132127
},
133128
{
134129
"description": "first base is negative",
135130
"property": "rebase",
136131
"input_base": -2,
137132
"input_digits": [1],
138133
"output_base": 10,
139-
"expected": null
134+
"expected": {"error": "input base must be >= 2"}
140135
},
141136
{
142137
"description": "negative digit",
143138
"property": "rebase",
144139
"input_base": 2,
145140
"input_digits": [1, -1, 1, 0, 1, 0],
146141
"output_base": 10,
147-
"expected": null
142+
"expected": {"error": "all digits must satisfy 0 <= d < input base"}
148143
},
149144
{
150145
"description": "invalid positive digit",
151146
"property": "rebase",
152147
"input_base": 2,
153148
"input_digits": [1, 2, 1, 0, 1, 0],
154149
"output_base": 10,
155-
"expected": null
150+
"expected": {"error": "all digits must satisfy 0 <= d < input base"}
156151
},
157152
{
158153
"description": "second base is one",
159154
"property": "rebase",
160155
"input_base": 2,
161156
"input_digits": [1, 0, 1, 0, 1, 0],
162157
"output_base": 1,
163-
"expected": null
158+
"expected": {"error": "output base must be >= 2"}
164159
},
165160
{
166161
"description": "second base is zero",
167162
"property": "rebase",
168163
"input_base": 10,
169164
"input_digits": [7],
170165
"output_base": 0,
171-
"expected": null
166+
"expected": {"error": "output base must be >= 2"}
172167
},
173168
{
174169
"description": "second base is negative",
175170
"property": "rebase",
176171
"input_base": 2,
177172
"input_digits": [1],
178173
"output_base": -7,
179-
"expected": null
174+
"expected": {"error": "output base must be >= 2"}
180175
},
181176
{
182177
"description": "both bases are negative",
183178
"property": "rebase",
184179
"input_base": -2,
185180
"input_digits": [1],
186181
"output_base": -7,
187-
"expected": null
182+
"expected": {"error": "input base must be >= 2"}
188183
}
189184
]
190185
}

0 commit comments

Comments
 (0)