Barry Warsaw | 04f357c | 2002-07-23 19:04:11 +0000 | [diff] [blame] | 1 | from test import test_support |
Tim Peters | 46c04e1 | 2002-05-05 20:40:00 +0000 | [diff] [blame] | 2 | import random |
| 3 | |
| 4 | # Ensure that the seed() method initializes all the hidden state. In |
| 5 | # particular, through 2.2.1 it failed to reset a piece of state used by |
| 6 | # (and only by) the .gauss() method. |
| 7 | |
| 8 | for seed in 1, 12, 123, 1234, 12345, 123456, 654321: |
| 9 | for seeder in random.seed, random.whseed: |
| 10 | seeder(seed) |
| 11 | x1 = random.random() |
| 12 | y1 = random.gauss(0, 1) |
| 13 | |
| 14 | seeder(seed) |
| 15 | x2 = random.random() |
| 16 | y2 = random.gauss(0, 1) |
| 17 | |
| 18 | test_support.vereq(x1, x2) |
| 19 | test_support.vereq(y1, y2) |