diff --git a/lib/date.rb b/lib/date.rb index 66fa67a..070cf7f 100644 --- a/lib/date.rb +++ b/lib/date.rb @@ -1478,11 +1478,9 @@ class Date # we reach +limit+ (inclusive), yielding the resultant # date at each step. def step(limit, step=1) # :yield: date -=begin if step.zero? raise ArgumentError, "step can't be 0" end -=end unless block_given? return to_enum(:step, limit, step) end diff --git a/test/date/test_date_arith.rb b/test/date/test_date_arith.rb index 745ddbd..00e1bac 100644 --- a/test/date/test_date_arith.rb +++ b/test/date/test_date_arith.rb @@ -261,6 +261,14 @@ class TestDateArith < Test::Unit::TestCase assert_equal(8, e.to_a.size) end + def test_step__0 + p = Date.new(2001,1,14) + q = Date.new(2001,1,21) + assert_raises(ArgumentError) do + p.step(q, 0){|d|} + end + end + =begin def test_step__inf p = Date.new(2001,1,14)