summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-random/test
diff options
context:
space:
mode:
authorEmiliano Lesende <[email protected]>2013-11-01 11:44:40 -0300
committerEmiliano Lesende <[email protected]>2013-11-01 11:44:40 -0300
commitd8cc37cdf95b72933ff3d8466b8ea3c4e3ff8010 (patch)
tree15d493371ceec9a1fd6c4fc6d532aca8df88cc08 /mrbgems/mruby-random/test
parent92825660ea94cde3b588ae0b1e4b0e9d311f718e (diff)
downloadmruby-d8cc37cdf95b72933ff3d8466b8ea3c4e3ff8010.tar.gz
mruby-d8cc37cdf95b72933ff3d8466b8ea3c4e3ff8010.zip
Added shuffle and shuffle! to the Array class in the Random gem.
Diffstat (limited to 'mrbgems/mruby-random/test')
-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