• ###### IgorSuharevcreated an issue for "Surreal Numbers Construction Rule" kata

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!

• ###### user2553318created a suggestion for "Surreal Numbers Construction Rule" kata

Published a python translation

• ###### Avantacommented on "Surreal Numbers Construction Rule" kata

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

• ###### alotaucommented on "Surreal Numbers Construction Rule" kata

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.

• ###### Voilecommented on "Surreal Numbers Construction Rule" kata

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? ;-)

• ###### alotaucommented on "Surreal Numbers Construction Rule" kata

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.

oops... :o

• ###### Voilecreated an issue for "Surreal Numbers Construction Rule" kata

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

• ###### alotaucommented on "Surreal Numbers Construction Rule" kata

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

• ###### Blind4Basicscommented on "Surreal Numbers Construction Rule" kata

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

• ###### alotaucommented on "Surreal Numbers Construction Rule" kata

`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.

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

Hope this clarifies. Thanks again for the feedback.

• ###### Blind4Basicscommented on "Surreal Numbers Construction Rule" kata
• 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"));
``````
• ###### alotaucommented on "Surreal Numbers Construction Rule" kata

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