Sha256: 84063b59de8041846abd6b44a10397c58c2816685f13e544b35aa3db77be8b2f
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
require 'microtest' require 'ae/legacy' require 'iteration' class TestArray < MicroTest::TestCase include AE::Legacy::Assertions def test_each_iteration a = [1,2,3] r = [ [1, 0, true , false, [] , [2,3]], [2, 1, false, false, [1] , [3] ], [3, 2, false, true, [1,2], [] ] ] i = 0 a.each_iteration do |it| value, index, first, last, prior, after = *r[i] assert_equal(value, it.value) assert_equal(index, it.index) assert_equal(first, it.first?) assert_equal(last, it.last?) assert_equal(prior, it.prior) assert_equal(after, it.after) i+=1 end end end class TestEnumerator < MicroTest::TestCase include AE::Legacy::Assertions def test_iteration e = [1,2,3].to_enum(:each) r = [ [1, 0, true , false, [] , [2,3]], [2, 1, false, false, [1] , [3] ], [3, 2, false, true, [1,2], [] ] ] i = 0 e.iteration do |it| value, index, first, last, prior, after = *r[i] assert_equal(value, it.value) assert_equal(index, it.index) assert_equal(first, it.first?) #assert_equal(last, it.last?) # TODO: when enumerators can report underlying object. assert_equal(prior, it.prior) #assert_equal(after, it.after) i+=1 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iteration-1.1.1 | test/test_iteration.rb |
iteration-1.1.0 | test/test_iteration.rb |