Bug #1794
Do not use random inside tests!!
Description
random
inside tests. Relevant files are
demo-Osaka2015.cocoa5
ErrMesg.cocoa5
test-ApproxSolve.cocoa5
Fix them!
History
#1
Updated by John Abbott 4 months ago
My g++
reports version info gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
My clang reports version info Ubuntu clang version 14.0.0-1ubuntu1.1
.
Is this bug reproducible on other platforms?
My current guess is that a random number generator behaves differently... but I've not yet looked at the code!
#2
Updated by John Abbott 4 months ago
- Status changed from New to In Progress
- % Done changed from 0 to 10
The cause is not too surprising: demo-Osaka2015.cocoa5
uses a random example (on line 72).
Evidently, with debugging active, some random numbers are used internally, and this affects the publicly visible sequence.
BTW I have verified that the problem exists also when compiling with g++
in debug mode. Curiously, the .cocoa5
files contains a comment saying what the random values are... but the comment is not the same as what is actually generated...
Ideally we would replace the randomness by specific "random" numbers.
#3
Updated by Anna Maria Bigatti 4 months ago
John Abbott wrote:
The cause is not too surprising:
demo-Osaka2015.cocoa5
uses a random example (on line 72).
Evidently, with debugging active, some random numbers are used internally, and this affects the publicly visible sequence.BTW I have verified that the problem exists also when compiling with
g++
in debug mode. Curiously, the.cocoa5
files contains a comment saying what the random values are... but the comment is not the same as what is actually generated...
For some reason (I cannot remember, but I think I knew it when it first happened, recently) the random values I'm getting now differ from the original version of the test (in the comment). I didn't think it depended on clang, so I changed the expected output.
Ideally we would replace the randomness by specific "random" numbers.
OK, I agree, especially if that changes with debugging on/off. Should I do it?
#4
Updated by John Abbott 3 months ago
- Status changed from In Progress to Resolved
- % Done changed from 10 to 70
random
is called harmlessly in exbugs.cocoa5
.
We should check ErrMesg.cocoa5
and test-ApproxSolve.cocoa5
; it is not clear to me that random
is used harmlessly in these files!!
#5
Updated by John Abbott 2 months ago
- Subject changed from Strange bug: demo-Osaka2015 to Do not use random inside tests!!
- Description updated (diff)