mirror of
https://github.com/ruby/ruby.git
synced 2025-09-18 18:13:58 +02:00
* array.c (rb_ary_sample): rename #choice to #sample. in
addition, sample takes optional argument, a la #first. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
130e720253
commit
9295fd4b59
3 changed files with 47 additions and 11 deletions
|
@ -1518,9 +1518,13 @@ class TestArray < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
def test_choice
|
||||
def test_sample
|
||||
100.times do
|
||||
assert([0, 1, 2].include?([2, 1, 0].choice))
|
||||
assert([0, 1, 2].include?([2, 1, 0].sample))
|
||||
samples = [2, 1, 0].sample(2)
|
||||
samples.each{|sample|
|
||||
assert([0, 1, 2].include?(sample))
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue