From d8cc37cdf95b72933ff3d8466b8ea3c4e3ff8010 Mon Sep 17 00:00:00 2001 From: Emiliano Lesende Date: Fri, 1 Nov 2013 11:44:40 -0300 Subject: Added shuffle and shuffle! to the Array class in the Random gem. --- mrbgems/mruby-random/test/random.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'mrbgems/mruby-random/test/random.rb') 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 -- cgit v1.2.3