summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-11 10:00:47 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-11 10:00:47 +0000
commit887eaf45d498c3ef024a97d763a7c22500e17329 (patch)
treeed93074b4e938f55f06c2fa5d8e4f21eb77faf81 /test/ruby/test_array.rb
parent3a47a3da85a9a841d6324f37d592cd3354e2da91 (diff)
downloadruby-887eaf45d498c3ef024a97d763a7c22500e17329.tar.gz
ruby-887eaf45d498c3ef024a97d763a7c22500e17329.tar.xz
ruby-887eaf45d498c3ef024a97d763a7c22500e17329.zip
* array.c (rb_ary_sample): rename #choice to #sample. in
addition, sample takes optional argument, a la #first. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 42553d193..7258b22a5 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -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