diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-07-28 16:01:58 -0700 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-07-28 16:01:58 -0700 |
| commit | 5ed89a401c72e521806fef6143e12f77c16bf8b7 (patch) | |
| tree | 45765f5489aa228f4e461d75ff883664835a23ab /test | |
| parent | 919a84771bfb9d535d56d68a49e60567ecda2253 (diff) | |
| parent | a2aa7e7f520b42a2de393039bd8d468dbd299026 (diff) | |
| download | mruby-5ed89a401c72e521806fef6143e12f77c16bf8b7.tar.gz mruby-5ed89a401c72e521806fef6143e12f77c16bf8b7.zip | |
Merge pull request #399 from akuroda/array_first_fix
fix segmentation fault in Array#first
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/array.rb | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/t/array.rb b/test/t/array.rb index 7029cd3c6..cb99cea6a 100644 --- a/test/t/array.rb +++ b/test/t/array.rb @@ -118,7 +118,24 @@ assert('Array#first', '15.2.12.5.13') do a = [] b = [1,2,3] - a.first == nil and b.first == 1 + e2 = nil + e3 = nil + begin + # this will cause an exception due to the wrong argument + [1,2,3].first(-1) + rescue => e1 + e2 = e1 + end + begin + # this will cause an exception due to the wrong argument + [1,2,3].first(1,2) + rescue => e1 + e3 = e1 + end + + a.first == nil and b.first == 1 and b.first(0) == [] and + b.first(1) == [1] and b.first(4) == [1,2,3] and + e2.class == ArgumentError and e3.class == ArgumentError end assert('Array#index', '15.2.12.5.14') do |
