Ad
  • Custom User Avatar

    Sorry, I figured it out, but I was confused by empty arrays with nil and zero length

  • Default User Avatar

    ... this is exactly why I want test frameworks to use this wording instead: expected X but got Y

    the wording used here makes sense when interacting with the test code, but the test code is hidden, it's the opposite of that. it should instead focus on presenting the result :s -- having the test read "expected Y" when in reality it expects X is just silly.

  • Custom User Avatar

    I'm not natan, but did you consider what happens to negative numbers when they're squared? :P

    In your example, if you take the first number -95 and square it, you get 9025, which is not the smallest number at all... But it exists in 2nd array, just like all the other numbers.

  • Default User Avatar

    @HarryTurney, I literally just saw the same problem on the previous post, and that one was in C++ . . .

    so, B1ts is entirely right about the confusion that can occur when you are not aware of the actual input

  • Custom User Avatar
    should handle random cases
    Log
    array1: [-35 -93 -53 -89 -35 16 88 96 10 74 76 64 72 36 -95 40 -89 -33]
    array2: [100 256 1089 1225 1225 1296 1600 2809 4096 5184 5476 5776 7744 7921 7921 8649 9025 9216]
    array1 sorted: [-95 -93 -89 -89 -53 -35 -35 -33 10 16 36 40 64 72 74 76 88 96]
    array2 sorted: [100 256 1089 1225 1225 1296 1600 2809 4096 5184 5476 5776 7744 7921 7921 8649 9025 9216]
    false
    Expected
        <bool>: false
    to equal
        <bool>: true
    

    @natan
    what exactly expected "false" in this case and what same it got "true" ??
    I return "false", as expected, but test say I return "true"

  • Custom User Avatar

    Not sure why you're so stubbon on this, that if statment isn't going to change anything

    Dude, it's literally the source of your bug, that's why I'm "stubborn" about it. Your conditional returns false for valid inputs, so you never print those test cases.

    By moving those print statements before the conditional, here's the last few lines of output that I see:

    -------------
    []
    []
    
    Expected
        <bool>: false
    to equal
        <bool>: true
    

    This is the failing test, not whatever you posted before. Does that make sense now? Or are you just gonna keep downvoting me and being convinced the kata is broken?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I am printing them at the beginning of the function

    Well then what is there on the next line after func ?! It doesn't look like a print statement to me.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    You're making a classic mistake of printing stuff NOT at the beginning of function. Your first if condition is not entirely correct, so you're not even seeing the test that actually failed.

    The tests are fine, not a kata issue.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    He's right, this fails in go.

    [11 19 19 19 121 144 144 161]
    [121 361 361 14641 20736 20736 25921 36100]

    121 - 121
    361 - 361
    361 - 361
    361 - 14641
    False

    3 19s but only 2 361s