summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-random/test/random.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-11-01 20:31:16 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2013-11-01 20:31:16 -0700
commitd2451dfb1660c219e7ba7bc2ae4ee859040b8d84 (patch)
tree15d493371ceec9a1fd6c4fc6d532aca8df88cc08 /mrbgems/mruby-random/test/random.rb
parent92825660ea94cde3b588ae0b1e4b0e9d311f718e (diff)
parentd8cc37cdf95b72933ff3d8466b8ea3c4e3ff8010 (diff)
downloadmruby-d2451dfb1660c219e7ba7bc2ae4ee859040b8d84.tar.gz
mruby-d2451dfb1660c219e7ba7bc2ae4ee859040b8d84.zip
Merge pull request #1557 from 3miliano/master
Added shuffle and shuffle! to the Array class in the Random gem.
Diffstat (limited to 'mrbgems/mruby-random/test/random.rb')
-rw-r--r--mrbgems/mruby-random/test/random.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/mrbgems/mruby-random/test/random.rb b/mrbgems/mruby-random/test/random.rb
index 01d231d5c..b35acaafd 100644
--- a/mrbgems/mruby-random/test/random.rb
+++ b/mrbgems/mruby-random/test/random.rb
@@ -30,3 +30,17 @@ end
assert("float") do
rand.class == Float
end
+
+assert("Array#shuffle") do
+ ary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ shuffled = ary.shuffle
+
+ ary == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and shuffled != ary and 10.times { |x| ary.include? x }
+end
+
+assert('Array#shuffle!') do
+ ary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ ary.shuffle!
+
+ ary != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and 10.times { |x| ary.include? x }
+end \ No newline at end of file