Skip to content

Commit

Permalink
Added test case for Iterator#map_with_index
Browse files Browse the repository at this point in the history
  • Loading branch information
KCreate authored and asterite committed Dec 24, 2016
1 parent 12ceb51 commit 929a551
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/std/enumerable_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ describe "Enumerable" do
result = ["Alice", "Bob"].map_with_index { |name, i| "User ##{i}: #{name}" }
result.should eq ["User #0: Alice", "User #1: Bob"]
end

it "yields the element and the index of an iterator" do
str = "hello"
result = str.each_char.map_with_index { |char, i| "#{char}#{i}" }
result.should eq ["h0", "e1", "l2", "l3", "o4"]
end
end

describe "max" do
Expand Down

0 comments on commit 929a551

Please sign in to comment.