-
-
Notifications
You must be signed in to change notification settings - Fork 554
Description
problem-specifications/exercises/list-ops/canonical-data.json
Lines 161 to 170 in 69395c4
{ | |
"description": "direction dependent function applied to non-empty list", | |
"property": "foldl", | |
"input": { | |
"list": [2, 5], | |
"initial": 5, | |
"function": "(x, y) -> x / y" | |
}, | |
"expected": 0 | |
} |
problem-specifications/exercises/list-ops/canonical-data.json
Lines 196 to 205 in 69395c4
{ | |
"description": "direction dependent function applied to non-empty list", | |
"property": "foldr", | |
"input": { | |
"list": [2, 5], | |
"initial": 5, | |
"function": "(x, y) -> x / y" | |
}, | |
"expected": 2 | |
} |
The two cases instruct the test implementation to apply the division operator /
to the two arguments of the function used for folding.
This operator is ambiguous, depending on language and circumstances. There are languages which always do floating-point division with /
and have a separate operator for integer division (eg div
in Erlang
), others do integer division if both operands are integers and float division only if at least one operand is a float, etc.
The current test cases in question assume integer division, but this is not obvious, only if you (as a human) read the test arguments and expected outcome carefully. For a test generator on the other hand, it is quite difficult.
As finding a language-agnostic way to explicitly specify integer division would pose rather difficult, I suggest to alter the test cases to use another direction-dependent but unambiguous operation instead, like -
.