mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merges r26936 from trunk into ruby_1_9_1 and little refactoring.
-- * random.c (rb_reset_random_seed): set seed in this. [ruby-core:28655] -- * random.c: refactoring. * random.c (rand_srand): a new function that wraps rand_init and (re)initialization of the random seed as a VALUE. * random.c (genrand_int32, genrand_real, rb_f_rand, rb_f_srand): using rand_srand. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@28511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
58a4828163
commit
237fc68839
4 changed files with 53 additions and 9 deletions
|
|
@ -164,4 +164,14 @@ class TestRand < Test::Unit::TestCase
|
|||
srand(0)
|
||||
assert_equal([1,4,2,5,3], [1,2,3,4,5].shuffle)
|
||||
end
|
||||
|
||||
def test_fork_shuffle
|
||||
pid = fork do
|
||||
(1..10).to_a.shuffle
|
||||
raise 'default seed is not set' if srand == 0
|
||||
end
|
||||
p2, st = Process.waitpid2(pid)
|
||||
assert(st.success?)
|
||||
rescue NotImplementedError, ArgumentError
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue