summaryrefslogtreecommitdiff
path: root/test/date/test_date_arith.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-25 04:28:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-25 04:28:11 +0000
commitd3d845396e658dfc8b6b1576e23e00085d5a823c (patch)
treec21649f16a698b6e623e2b39c228558e24152968 /test/date/test_date_arith.rb
parente110c0ddc5e9d07821f8e7d5d0a7de96fe826eab (diff)
date_core.c: defensive code
* ext/date/date_core.c (f_cmp): check comparison failure. * ext/date/date_core.c (d_lite_step): deal with the comparison result more defensively. [ruby-core:85796] [Bug #14549] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/date/test_date_arith.rb')
-rw-r--r--test/date/test_date_arith.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/date/test_date_arith.rb b/test/date/test_date_arith.rb
index 96622ba065..d0d27d72f7 100644
--- a/test/date/test_date_arith.rb
+++ b/test/date/test_date_arith.rb
@@ -262,4 +262,17 @@ class TestDateArith < Test::Unit::TestCase
assert_equal(8, e.to_a.size)
end
+ def test_step__compare
+ o = Object.new
+ def o.<=>(*);end
+ assert_raise(ArgumentError) {
+ Date.new(2000, 1, 1).step(3, o).to_a
+ }
+
+ o = Object.new
+ def o.<=>(*);2;end
+ a = []
+ Date.new(2000, 1, 1).step(3, o) {|d| a << d}
+ assert_empty(a)
+ end
end