Pass comparison callback to sort radix-sort.test.js#29
Pass comparison callback to sort radix-sort.test.js#29Mindgames55 wants to merge 1 commit intobtholt:mainfrom
Conversation
**unit tests bug** unit tests rely on `Array.sort` . However, there is no comparison function which will sort the array as they were strings. Not sure why tests passed in the case of the solution file. Sandbox is not very good for debugging but test should also fail in there bc of the bug in the test not the algo
|
I noticed that the solution tests are actually skipped by default... however they do pass (incorrectly). The reason they pass is that the unit test is written in a way that the expectation and the result are the same array object and so you're doing a comparison on itself. Copying the array and sorting it separately from the input passed to radix-sort demonstrates this if you modify the test to be:
the test will not pass. (i.e your commit is necessary to fix the unit test, but also the test is written in a way that means nothing if you write your sorting function in a specific way) |
unit tests bug
unit tests rely on
Array.sort. However, there is no comparison function which will sort the array as they were strings.Not sure why tests passed in the case of the solution file. Sandbox is not very good for debugging but test should also fail in there bc of the bug in the test not the algo