<div>Hello List,</div><div><br></div><div>I just found a bahaviour I didn't expect in OTPs random module, it's not necessarily a bug but I thought I'd share it here all the same.</div><div><br></div><div>I wrote a simple random data generator using random:uniform() to help me track a bug that was triggered by certain input data that I couldn't catch. The minimal example is attached in demo.erl.</div>
<div><br></div><div>If you run the test function it will probably pass a few times but will eventually hit my "bug" and fail. Whenever the bug is triggered the test function gets a badmatch and the current process dies. The behaviour I wasn't expecting now occurs, everytime I repeat the test function I get the exact same sequence of numbers from random:uniform.</div>
<div><br></div><div>I can call random:uniform from the shell to move it on one step in the sequence and probably pass another test, but when it fails again my process dies and again I repeatedly get a repeated sequence of numbers. The sequence from this second fail is different from the first fail so it hasn't just gone back to the start.</div>
<div><br></div><div>I don't expect to be saved from my own bugs but just thought this was a strange behaviour from random. If anyone is using random in their application they should be aware of this.</div><div><br></div>
<div>//Tom.</div><div><br></div><div><br></div><div><div>8> demo:test_my_buggy_code().</div><div>ok - [15,21,70,16,56,22,46,43,1,57]</div><div>ok</div><div>9> demo:test_my_buggy_code().</div><div>ok - [41,31,6,58,99,34,19,21,4,89]</div>
<div>ok</div><div>10> demo:test_my_buggy_code().</div><div>ok - [83,33,26,81,2,3,5,6,99,57]</div><div>ok</div><div>11> demo:test_my_buggy_code().</div><div>** exception error: no match of right hand side value [1,39,67,88,90,80,59,30,</div>
<div> 72,41,80]</div><div> in function demo:test_my_buggy_code/0</div><div> in call from random:uniform/0</div><div>12> demo:test_my_buggy_code().</div><div>
** exception error: no match of right hand side value [1,39,67,88,90,80,59,30,</div><div> 72,41,80]</div><div> in function demo:test_my_buggy_code/0</div><div> in call from random:uniform/0</div>
<div>13> random:uniform(1). </div><div><div>1</div><div>14> demo:test_my_buggy_code().</div><div>ok - [67,88,90,80,59,30,72,41,80,8]</div><div>ok</div><div>15> demo:test_my_buggy_code().</div><div>ok - [60,68,65,8,27,61,1,94,82,65]</div>
<div>ok</div><div>16> demo:test_my_buggy_code().</div><div>ok - [47,2,62,94,25,97,94,87,27,32]</div><div>ok</div><div>17> demo:test_my_buggy_code().</div><div>ok - [59,21,10,14,17,24,93,78,34,28]</div><div>ok</div><div>
18> demo:test_my_buggy_code().</div><div>** exception error: no match of right hand side value [1,3,59,96,93,32,99,34,</div><div> 60,42,2]</div><div> in function demo:test_my_buggy_code/0</div>
<div> in call from random:uniform/0</div><div>19> demo:test_my_buggy_code().</div><div>** exception error: no match of right hand side value [1,3,59,96,93,32,99,34,</div><div> 60,42,2]</div>
<div> in function demo:test_my_buggy_code/0</div><div> in call from random:uniform/0</div><div>20> demo:test_my_buggy_code().</div><div>** exception error: no match of right hand side value [1,3,59,96,93,32,99,34,</div>
<div> 60,42,2]</div><div> in function demo:test_my_buggy_code/0</div><div> in call from random:uniform/0</div><div>21> </div><div><br></div></div></div>