summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-random/test/random.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-11-24 09:13:34 +0900
committerGitHub <[email protected]>2016-11-24 09:13:34 +0900
commit2c28d00356c13f1c2bf4d2f6f5e8943c17fea518 (patch)
treecdd1806ffc3caed8d83973fa04fc71629c4ce5fa /mrbgems/mruby-random/test/random.rb
parent669bbc70b0553b68483c8d7eff8c31a602f283e9 (diff)
parentc7262be0aeaf55b5c92b26db82c08f2fe6b95412 (diff)
downloadmruby-2c28d00356c13f1c2bf4d2f6f5e8943c17fea518.tar.gz
mruby-2c28d00356c13f1c2bf4d2f6f5e8943c17fea518.zip
Merge pull request #3268 from bouk/fix-random-segfault
Fix segfault in Array#sample
Diffstat (limited to 'mrbgems/mruby-random/test/random.rb')
-rw-r--r--mrbgems/mruby-random/test/random.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/mrbgems/mruby-random/test/random.rb b/mrbgems/mruby-random/test/random.rb
index 1653ae4a6..1c59be3a6 100644
--- a/mrbgems/mruby-random/test/random.rb
+++ b/mrbgems/mruby-random/test/random.rb
@@ -74,3 +74,15 @@ assert('Array#shuffle!(random)') do
ary1 != [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and 10.times { |x| ary1.include? x } and ary1 == ary2
end
+
+assert('Array#sample checks input length after reading arguments') do
+ $ary = [1, 2, 3]
+ class ArrayChange
+ def to_i
+ $ary << 4
+ 4
+ end
+ end
+
+ assert_equal [1, 2, 3, 4], $ary.sample(ArrayChange.new).sort
+end