Created
June 17, 2011 20:44
-
-
Save pazustep/1032299 to your computer and use it in GitHub Desktop.
each_with_index.map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EachWithIndexTest < Test::Unit::TestCase | |
def setup | |
@array = ["one", "two", "three"] | |
end | |
def test_each_with_index_enumerator | |
enum = @array.each_with_index | |
assert_equal ["one", 0], enum.next | |
end | |
def test_each_with_index_and_map | |
@array.each_with_index.map do |item, index| | |
assert_not_nil item | |
assert_not_nil index | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment