In the exercise "high-scores" the three functions under test receive an offset and a length.
IMHO the name and description of the "length" imply that this parameter contains the number of elements.
But it actually contains the length of the array in bytes.
Concrete:
In the initial stub the parameter is named $inputElements with the explanation "number of u32 elements in the input".
https://github.com/exercism/wasm/blob/main/exercises/practice/high-scores/high-scores.wat#L8
The tests multiply the length of the array with u32Size to get the number of bytes and pass that "encodedLength" to the function under test
https://github.com/exercism/wasm/blob/main/exercises/practice/high-scores/high-scores.spec.js#L27-L39
In contrast:
In the exercise "binary-search" the tests pass the haystack.length (the number of elements) to the function under test.
https://github.com/exercism/wasm/blob/main/exercises/practice/binary-search/binary-search.spec.js#L37
And the initial stub correctly describes the parameter as "@PARAM {i32} nelems - the number of elements in the haystack"
https://github.com/exercism/wasm/blob/main/exercises/practice/binary-search/binary-search.wat#L8
I think this is inconsistent and misleading.
IMHO the tests should pass the number of elements to the function under test.
In the exercise "high-scores" the three functions under test receive an offset and a length.
IMHO the name and description of the "length" imply that this parameter contains the number of elements.
But it actually contains the length of the array in bytes.
Concrete:
In the initial stub the parameter is named
$inputElementswith the explanation "number of u32 elements in the input".https://github.com/exercism/wasm/blob/main/exercises/practice/high-scores/high-scores.wat#L8
The tests multiply the length of the array with
u32Sizeto get the number of bytes and pass that "encodedLength" to the function under testhttps://github.com/exercism/wasm/blob/main/exercises/practice/high-scores/high-scores.spec.js#L27-L39
In contrast:
In the exercise "binary-search" the tests pass the
haystack.length(the number of elements) to the function under test.https://github.com/exercism/wasm/blob/main/exercises/practice/binary-search/binary-search.spec.js#L37
And the initial stub correctly describes the parameter as "@PARAM {i32} nelems - the number of elements in the haystack"
https://github.com/exercism/wasm/blob/main/exercises/practice/binary-search/binary-search.wat#L8
I think this is inconsistent and misleading.
IMHO the tests should pass the number of elements to the function under test.