• Custom User Avatar

    As I thought after reading the kata's description, there are only two types of numbers in given string:

    • the integer number, i.e. 0, 13456, -25214, etc.
    • the ratio A/B or -A/B, where A and B are non-negative integer numbers and B != 0.
      Thus, numbers like 1.7976931348623157E308, 4.9E-324, 0.4445839983169688 are absent in given strings guaranteed.

    Howeher, there are tests with exactly these numbers!
    Please, explain.

  • Custom User Avatar

    Published a python translation

  • Custom User Avatar

    added random tests

  • Default User Avatar

    You want random tests so that other people can't hardcode your test cases

  • Custom User Avatar

    I should indeed be fixing my solution if it is incorrect. It's still not clear to me how a random test is going to help me identify an issue with my solution. The parameters I put into building valid random problems are going to be the same ones I use to build my deterministic tests. Specifically, the limits I place on the random numbers generated are the same limits I use for my edge cases.

    Anyway, I'll think about it a little more.

  • Custom User Avatar

    Random tests is a sure fire way to easily reject invalid solutions. It also prevents people from pattern-matching results from inputs.

    (Of course, edge case tests are good too, but they're not easy to come up and you don't want to write lots of them yourselves.)

    Also, if your solution is incorrect, then you should be fixing it, right? ;-)

  • Custom User Avatar

    I'm really having trouble seeing the value of random tests, at least for this kata. Seems like they would be meant for testing my solution more than other folks', right? The implication is that there are classes of tests that are not covered by the existing (deterministic) tests and the random test might hit one such class of tests. Is that correct?

    Any insight appreciated.

  • Default User Avatar
  • Custom User Avatar

    Who approved this kata when the random tests aren't done yet?

  • Custom User Avatar

    yep... will keep adding. these are good ones.

  • Default User Avatar

    ok, I haven't seen the modification of the description.

  • Custom User Avatar

    assertEquals(true, sc.isSurreal("", "")); => should be false (that is... if you keep it... ;) )

    Is correct as written. In the def'n of surreal numbers, the empty set on either (or both) sides has special meaning. Note the definition of the form in the description... intersection is the empty set and all elements of L are less than all elements of R. Empty set on both sides satisfies this, but "1" on both sides does not. Empty set on both sides is extra special as it defines "0" in this number system (the first number that is possible to generate).

    So, I'm happy to keep the empty string to represent the empty set and follow rules of surreal numbers.

    Note that I had added the text:

    "One or both strings may be empty and in this case the form represents a valid surreal number and isSurreal should return true."

    prior to adding those tests.

    Hope this clarifies. Thanks again for the feedback.

  • Default User Avatar
    • Random tests: that's the idea, yes (do not forget to declare the related methods/class as private in the test class). Be careful when generating the fractions, to avoid division by 0.
    • Empty string: not sure this one is a good idea. Meaning: just look at the solutions: they are all invalid, right now. If you keep that test (it's completely up to you), you introduce new features in your kata (input validation, somehow), so you should at least put it in the description. But doing so, you open the pandora's box: what about wrong formatted strings? letters? division by zero too, for instance? So maybe not the better choice to keep the empty string (especially when you already explain that numbers will be well formed in the description). Your choice, again, but keeping it will need a lot more work (well, "could be", at least).

    If you want some input about random test, jsut take a look at the test cases of other kata you already solved.

    EDIT: Warning, those two are incoherent:

    assertEquals(true, sc.isSurreal("", ""));    => should be false (that is... if you keep it... ;) )
    assertEquals(false, sc.isSurreal("1", "1"));
  • Custom User Avatar

    Added max(L) == min(R) cases to tests.

    Added empty set ("") tests.

    Will leave this open until I get around to writing random tests.

    Any pointers to writing random tests? I have never written one. Assuming I have to generate reasoanble random strings of numbers, then use my solution as truth for the return value. Is that about it?


  • Custom User Avatar

    Thanks for feedback. Will work on that.

  • Loading more items...