diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-28 23:21:42 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-28 23:21:42 +0900 |
| commit | 7d413b7043d905dda432d9703c4612ac1bb4b612 (patch) | |
| tree | 4016272509d2a3dbc575f8a02ab77a2c648fc151 /mrbgems/mruby-array-ext/test | |
| parent | 97f22c9516c2fdf2c0dc93099e20fc110ac9456d (diff) | |
| parent | e8cb971bbbdb2f6dee0628f950c6b8094cb5f09d (diff) | |
| download | mruby-7d413b7043d905dda432d9703c4612ac1bb4b612.tar.gz mruby-7d413b7043d905dda432d9703c4612ac1bb4b612.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'mrbgems/mruby-array-ext/test')
| -rw-r--r-- | mrbgems/mruby-array-ext/test/array.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mrbgems/mruby-array-ext/test/array.rb b/mrbgems/mruby-array-ext/test/array.rb index 1c441cec4..ab830cca7 100644 --- a/mrbgems/mruby-array-ext/test/array.rb +++ b/mrbgems/mruby-array-ext/test/array.rb @@ -107,3 +107,14 @@ assert("Array#compact!") do a.compact! a == [1, "2", :t, false] end + +assert("Array#fetch") do + a = [ 11, 22, 33, 44 ] + assert_equal 22, a.fetch(1) + assert_equal 44, a.fetch(-1) + assert_equal 'cat', a.fetch(4, 'cat') + ret = 0 + a.fetch(100) { |i| ret = i } + assert_equal 100, ret + assert_raise(IndexError) { a.fetch(100) } +end |
