From 9295fd4b5978dbb51aabc3981a245aacd7ffcac5 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 11 Aug 2008 10:00:47 +0000 Subject: * 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 --- test/ruby/test_array.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 42553d1932..7258b22a5b 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 -- cgit v1.2.3