Juan-Carlos Gandhi (
juan_gandhi) wrote2020-08-23 09:18 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Entry tags:
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.
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.
Re: How to test nondeterministic functions
Re: How to test nondeterministic functions
People that are clueless regarding what is function.
Re: How to test nondeterministic functions
Re: How to test nondeterministic functions
You won't understand my answer. That's one of the signs.
"Idiots" sign
Re: "Idiots" sign
As if I care.
Whom here do you understand, name one.
Re: "Idiots" sign
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.
Re: "Idiots" sign
No, you did not.
Sings of understanding
Re: Sings of understanding
You won't understand my answer either.
Re: Sings of understanding
Still, lack of answer suggests: unwillingness to teach and unwillingness to expose your thoughts for external testing.
Re: Sings of understanding
I said I don't care. Why would I? I'm not your teacher. You want to learn something - learn something. Buy my book, read it and ask questions. When done, we can talk.
The book
Why do you think your book will teach me what I need?
Re: The book
It obviously won't. You seem to be unteachable. And I don't know what you need.
Re: The book
Then why did you recommend to buy your book?
Re: The book
For the case you change, with time.
Also, https://juan-gandhi.dreamwidth.org/4300834.html
Re: The book
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?