Skip to content

Commit

Permalink
Support svalue
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Dec 1, 2016
1 parent 0f774ff commit 2718fed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mrbgems/mruby-enumerator/mrblib/enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ def with_index(offset=0)
end

n = offset - 1
enumerator_block_call do |i|
enumerator_block_call do |*i|
n += 1
yield [i,n]
yield i.__svalue, n
end
end

Expand Down
3 changes: 3 additions & 0 deletions mrbgems/mruby-enumerator/test/enumerator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def foo *a
assert 'Enumerator#with_index' do
assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a)
assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a)
a = []
@obj.to_enum(:foo, 1, 2, 3).with_index(10).with_index(20) { |*i| a << i }
assert_equal [[[1, 10], 20], [[2, 11], 21], [[3, 12], 22]], a
end

assert 'Enumerator#with_index nonnum offset' do
Expand Down

0 comments on commit 2718fed

Please sign in to comment.