Doctest stdlib timerelated#11327
Conversation
CT Test Results 2 files 100 suites 1h 7m 31s ⏱️ For more details on these failures, see this check. Results for commit 25c69b8. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
| 2> F = random:uniform(), is_float(F), F > 0.0, F < 1.0. | ||
| true |
There was a problem hiding this comment.
This results in true for any F that is a number (including integers) that is less than 1.0, for example -5.
There was a problem hiding this comment.
Thanks for pointing it . The idea was to demonstrate output as floating and between 0.0 and 1.0. Added 'and' operator now to correct the same than the 'comma' operator. Hope now is ok
| 3> I = random:uniform(10), I >= 1, I =< 10. | ||
| true |
There was a problem hiding this comment.
This results in true for any I that is a number (including floats) that is less than or equal to 10, for example -5.5.
| 2> {Float, _NewState} = random:uniform_s(State), is_float(Float), Float > 0.0, Float < 1.0. | ||
| true |
There was a problem hiding this comment.
This results in true for any Float that is a number (including integers) that is less than 1.0, for example -5.
| 3> {Int, _NewState2} = random:uniform_s(10, State), Int >= 1, Int =< 10. | ||
| true |
There was a problem hiding this comment.
This results in true for any Int that is a number (including floats) that is less than or equal to 10, for example -5.5.
| 1> ok = element(1, timer:apply_after(5000, io, format, ["~nHello World!~n", []])). | ||
| ok |
There was a problem hiding this comment.
This wrapping in element(1, ...) makes the examples pretty confusing. A newcomer will certainly wonder, "Is that needed? What for? 🤔"?
There was a problem hiding this comment.
I agree that it makes the example not too clear enough for beginers. I have reverted preexisting examples at start of document back to text script. For newer added examples, since the TRef that is given by apply_after is always dynamic its hard to pattern match output and fails by doctest function in performed by timer_suite module. As per my understanding, examples should pass doctest at anypoint and hence a way verifying they are correct , so here TRef being dynamically generated will not be able to pattern match and hence extracting first element 'ok which will also validate success. I am happy to discuss any other better method that could be adopted otherwise :)
This PR adds doctest examples to time related modules in Stdlib application for most of the functions