Ad
  • Custom User Avatar

    There are several problems with this kata:

    • The outer loop in your own solution and the test only runs Math.ceil(Math.log2(array.length)) times. Imagine the smallest value is at the right. You need array.length - 1 iterations of the inner loop to get it to the left.
    • The first argument of the function it is a description of the test. "Yes" is not a description.
    • The tests use Test.assertSimilar(). That function converts both arguments to strings and compares those strings. The message is unnecessarily hard to read. Use Test.asserDeepEquals() instead.
    • Disabling a function is hard. You call bubbleSort.toString() and search that string for the substring "sort". There are many techniques to circumvent that, e.g. what mrtp0 did.
    • In the random tests you call the model solution after the user's solution. The user could modify the array and thus change the test.
    • But the biggest problem is: There is already a Bubble Sort kata. The task is slightly different but the central task is to implement bubble sort, too.