summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-28 09:52:40 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-28 09:52:40 +0000
commit607927bf36a17a479b8e740d396b20c135d77ff3 (patch)
tree8dd8456bda19a64912f1466f82633d52a346a89d /test
parent954f4e009ec842e856581a9e302a9122a40cb178 (diff)
merge revision(s) 62572: [Backport #14549]
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/branches/ruby_2_5@62610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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