Ad
  • Custom User Avatar

    Thanks, got it :)

  • Custom User Avatar

    if name is not given (or passed as an empty String).

    It's your code's job to handle that case too.

  • Custom User Avatar

    In Python, one of the test cases try to call the function without an argument and fail.

  • Custom User Avatar

    My pleasure. Hope you will populate soon Codewars with new Rust katas, they are missing!

  • Custom User Avatar

    Thanks. This was my first one. I really appreciate your help.

  • Custom User Avatar

    Approved :)

    (next time you propose a translation for reviewal, you'd better put a suggestion flag to give it more visibility)

  • Custom User Avatar

    Done. And I made it 50. :)

  • Custom User Avatar

    You could also reduce the number of tests, though it doesn't matter that much (30 sets of tests would be enough)

  • Custom User Avatar

    Nice. Sorry to bother you again, but it's good to have robust tests, I've just realized a solution that would control erroneously the result rounding down n can sometimes pass the tests. I suggest to add another line like this:

                let w: f64 = rng.gen_range(0.0..=2.0);
                assert_eq!(plural(w), w!=1.0);
    

    This way it will be the most robust tests of all languages, and no rounding or truncating method will pass ;) As you can see on the Discourse page, Voile already raised an issue about weak tests in some languages. It's better to have robust tests in new translations :)

  • Custom User Avatar

    https://www.codewars.com/kumite/617663830a9ae1001aa15dea?sel=626ab7b4bae2950059360028

    Here's the fork. Thanks for your help. The gen_range() function changes how it takes the numbers between versions.

  • Custom User Avatar

    I get Language version is invalid if I try to approve. You need to update the version (fork this translation and select version 1.60, and control everything works fine).

  • Custom User Avatar

    I added that test, as well.

  • Custom User Avatar

    Yes but the idea is to test it also randomly in random tests. There is no point in having random tests if they all expect the same. You can refer to other languages to see how they do it.

  • Custom User Avatar

    Isn't 1.0 already tested in the regular cases?

  • Custom User Avatar

    Ok, tests now work, but random tests have a low probability to generate 1.0, so just return true passes most them of times. This is not big issue (this kata is really basic), but you should study to design random tests to be sure they always generate a certain amount of 1.0.

    You can refer to other languages. For example you could replace line 18 with:

          let x: f64 = (rng.gen_range(1.0, 10.0) as f64).floor();
    

    (there are other possibilities)

  • Loading more items...