juan_gandhi: (Default)
Juan-Carlos Gandhi ([personal profile] juan_gandhi) wrote2020-08-23 09:18 pm

TWIMC: tests using random and current time

 So, if you think you call a function in your code, and this function returns current time, or a random number... IT'S NOT A FUNCTION. Your code is function of "random number", or "time".

So, if your code is written as something that retrieves this kind of data, to test your code, you should provide that data. Not just today, but try the time, like 10 years from now. As to "random", You provide the randomness. If your code cannot be fixed to behave as a function of those inputs, make your "random stream" or "time stream" not hard-coded, but substitutable. Mockable. And mock it in your tests. MAKE SURE that you don't provide just happy-path data. Provide anything. A sequence of 100 numbers 4 for random. Time that is 10 years from now. Or even 30 yeas from now.

Make sure that your tests don't depend on anything. Because test Must Be Reproducible.

All these things, I know, are obvious to some, and not obvious to others.

If you still have questions, ask. But don't argue. Because what I say is math. Unless you have another math (some people do), or another logic (there's plenty of them), please don't argue.

I'd be glad to see how all this changes if logic is e.g. linear. 

 

dennisgorelik: 2020-06-13 in my home office (Default)

Re: How to test nondeterministic functions

[personal profile] dennisgorelik 2020-08-24 08:14 pm (UTC)(link)
What "idiots" are you referring to?
dennisgorelik: 2020-06-13 in my home office (Default)

Re: How to test nondeterministic functions

[personal profile] dennisgorelik 2020-08-24 09:39 pm (UTC)(link)
What are the signs that these people are clueless about what function is?
dennisgorelik: 2020-06-13 in my home office (Default)

"Idiots" sign

[personal profile] dennisgorelik 2020-08-24 11:24 pm (UTC)(link)
If I do not understand your answer -- this is a sign about you and me, not about other people.
dennisgorelik: 2020-06-13 in my home office (Default)

Re: "Idiots" sign

[personal profile] dennisgorelik 2020-08-24 11:49 pm (UTC)(link)
> Whom here do you understand, name one.

I understand almost everyone, including you.
It is your [incorrect] opinion that I do not understand you.
But most of the time I do understand. I just do not always agree.
Or, sometimes, I misunderstand. But, most of the time, I understand correctly.
Edited 2020-08-24 23:52 (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)

Sings of understanding

[personal profile] dennisgorelik 2020-08-25 03:24 pm (UTC)(link)
Why do you think that I do not understand almost everyone [who I choose to carefully read]?
dennisgorelik: 2020-06-13 in my home office (Default)

Re: Sings of understanding

[personal profile] dennisgorelik 2020-08-25 05:13 pm (UTC)(link)
If there is no answer -- it is hard to understand it.

Still, lack of answer suggests: unwillingness to teach and unwillingness to expose your thoughts for external testing.
dennisgorelik: 2020-06-13 in my home office (Default)

The book

[personal profile] dennisgorelik 2020-08-25 05:38 pm (UTC)(link)
> Buy my book

Why do you think your book will teach me what I need?
dennisgorelik: 2020-06-13 in my home office (Default)

Re: The book

[personal profile] dennisgorelik 2020-08-25 06:47 pm (UTC)(link)
> It obviously won't.

Then why did you recommend to buy your book?
Edited 2020-08-25 18:51 (UTC)
dennisgorelik: 2020-06-13 in my home office (Default)

Re: The book

[personal profile] dennisgorelik 2020-08-25 07:17 pm (UTC)(link)
> For the case you change, with time.

It would make more sense to recommend your book after this hypothetical change will happen, not before that, right?

> Also, https://juan-gandhi.dreamwidth.org/4300834.html

I am not sure what to take from it.
My guess is that you are tired?