- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/mruby-1.3.0
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-enumerator/test/enumerator.rb
r321 r331 51 51 assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).with_index.to_a) 52 52 assert_equal([[1,5],[2,6],[3,7]], @obj.to_enum(:foo, 1, 2, 3).with_index(5).to_a) 53 a = [] 54 @obj.to_enum(:foo, 1, 2, 3).with_index(10).with_index(20) { |*i| a << i } 55 assert_equal [[[1, 10], 20], [[2, 11], 21], [[3, 12], 22]], a 53 56 end 54 57 … … 61 64 assert 'Enumerator#with_index string offset' do 62 65 assert_raise(TypeError){ @obj.to_enum(:foo, 1, 2, 3).with_index('1').to_a } 66 end 67 68 assert 'Enumerator#each_with_index' do 69 assert_equal([[1,0],[2,1],[3,2]], @obj.to_enum(:foo, 1, 2, 3).each_with_index.to_a) 70 a = [] 71 @obj.to_enum(:foo, 1, 2, 3).each_with_index {|*i| a << i} 72 assert_equal([[1, 0], [2, 1], [3, 2]], a) 63 73 end 64 74
Note:
See TracChangeset
for help on using the changeset viewer.