Permalink
Browse files

Support svalue

  • Loading branch information...
ksss committed Dec 1, 2016
1 parent 0f774ff commit 2718fed1248872e6af436159a8f336fb54b86df2
Showing with 5 additions and 2 deletions.
  1. +2 −2 mrbgems/mruby-enumerator/mrblib/enumerator.rb
  2. +3 −0 mrbgems/mruby-enumerator/test/enumerator.rb
@@ -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
@@ -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

0 comments on commit 2718fed

Please sign in to comment.