diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-30 14:49:34 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-03-30 14:49:34 +0900 |
| commit | 898077a2c28def75b7894cea03f20bb8796b9d27 (patch) | |
| tree | 35ddd2f3f8076891546bd20fc502f82b985e824e /mrbgems/mruby-enumerator/test/enumerator.rb | |
| parent | 905f46a129de65098b3130789bb9c412201f4cb4 (diff) | |
| parent | d93a5c1a8417949769714be40aaf62121059da96 (diff) | |
| download | mruby-898077a2c28def75b7894cea03f20bb8796b9d27.tar.gz mruby-898077a2c28def75b7894cea03f20bb8796b9d27.zip | |
Merge pull request #3566 from okkez/fix-enumerator-each-with-index
Fix Enumerator#each_with_index with block
Diffstat (limited to 'mrbgems/mruby-enumerator/test/enumerator.rb')
| -rw-r--r-- | mrbgems/mruby-enumerator/test/enumerator.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/mrbgems/mruby-enumerator/test/enumerator.rb b/mrbgems/mruby-enumerator/test/enumerator.rb index e86e874f0..763cd36e2 100644 --- a/mrbgems/mruby-enumerator/test/enumerator.rb +++ b/mrbgems/mruby-enumerator/test/enumerator.rb @@ -65,6 +65,13 @@ assert 'Enumerator#with_index string offset' do assert_raise(TypeError){ @obj.to_enum(:foo, 1, 2, 3).with_index('1').to_a } end +assert 'Enumerator#each_with_index' do + assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).each_with_index.to_a) + a = [] + @obj.to_enum(:foo, 1, 2, 3).each_with_index {|*i| a << i} + assert_equal([[1, 0], [2, 1], [3, 2]], a) +end + assert 'Enumerator#with_object' do obj = [0, 1] ret = (1..10).each.with_object(obj) {|i, memo| |
