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: Is "nondeterministic function" a useful concept
But in the end if you understood the substance of what juan gandhi said, bickering about the term is pointless. And if you did not understand the substance, bickering about the term is shallow.
Re: Is "nondeterministic function" a useful concept
I am not "bickering". I have a very specific question.
Such as -- why use more ambiguous term "function" instead of more specific and very searchable "deterministic function"?
Re: Is "nondeterministic function" a useful concept
Math uses terms. What people on the internets say, does not matter. Your opinion, e.g., does not matter. My neither.
Re: Is "nondeterministic function" a useful concept
True, but irrelevant to discussion about testing in programming.
> What people on the internets say, does not matter.
That is incorrect.
What people say on the internets -- matter, at least, to some degree.
> Your opinion, e.g., does not matter. My neither.
These are also incorrect statements.
Our opinions do matter.
Re: Is "nondeterministic function" a useful concept
I would rather you answered whether you understood the substance of the post.
If I cared.
Re: Is "nondeterministic function" a useful concept
If that specific question help to clarify the opponent's position -- then it is not bickering.
> whether you understood the substance of the post
What post?
Re: Is "nondeterministic function" a useful concept
It doesn't look like you have anything of substance to say.
Usage of term "deterministic function"
Are you implying that you did not write "No one outside SQL community uses that term."?
Sweeping the uncomfortable facts under the carpet
But then who would expect an admission that yes, the term appears to be SQL-only and doesn't really cut it as a serious objection to the use of a certain well-established term. Diversion is so much easier to play.
Misunderstanding question
> I am not implying, I am plain telling you that you haven't even read what you've found
You did not really answer my question here.
I asked you about "No one outside SQL community uses that term" statement, not about me reading or finding something.
Did you misunderstand my question or did you pretend to misunderstand it?
> Diversion is so much easier to play.
Is that what you are doing? Diversion?
Re: "то есть" trick
I am not inclined to answer your questions because you are not inclined to answer mine. Although by saying this I've just answered one of yours.
> Is that what you are doing?
This is a "то есть" trick of yours, so the best I can do is ignore.
Expecting answers to unasked questions
Yes.
That suggests that you are avoiding reaching clarity in our communication.
> because
That causality claim is wrong.
> you are not inclined to answer mine
This your hypothesis is wrong.
I am, actually, inclined to answer your questions, but you did not ask any questions [at least in the last 8 your replies to me].
Re: Expecting answers to unasked questions
Re: Expecting answers to unasked questions
Re: "то есть" trick
> This is a "то есть" trick of yours
What is "то есть" trick?
How is that trick relevant to my question?
> the best I can do is ignore
Nope.
Not entering discussion in the first place -- is a much better for saving time.
Answering the question is the best for reaching clarity.
Entering discussion and then not answer clarifying questions that pop up in that discussion -- is, usually, a bad choice. I disrespect such behavior.