diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-07 08:07:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-07 08:07:24 +0000 |
commit | 7ab3f98604a05d12d0323414db008b3938981e08 (patch) | |
tree | 4b0d33b05574fa8d1682efb1b1cc84efc653572b /test/date | |
parent | 7a363dd91fff378d2c93b4e27d13b2d4ba985e0d (diff) | |
download | ruby-7ab3f98604a05d12d0323414db008b3938981e08.tar.gz |
date_core.c: check conversion
* ext/date/date_core.c (offset_to_sec, d_lite_plus): check
conversion results, to get rid of infinite recursion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/date')
-rw-r--r-- | test/date/test_date_arith.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/date/test_date_arith.rb b/test/date/test_date_arith.rb index 94822e5764..e1f29dbf22 100644 --- a/test/date/test_date_arith.rb +++ b/test/date/test_date_arith.rb @@ -3,11 +3,18 @@ require 'test/unit' require 'date' class TestDateArith < Test::Unit::TestCase + class Rat < Numeric + def to_r; self; end + end def test_new_offset d = DateTime.new(2002, 3, 14) assert_equal(Rational(9, 24), d.new_offset(Rational(9, 24)).offset) assert_equal(Rational(9, 24), d.new_offset('+0900').offset) + n = Rat.new + assert_raise(TypeError) do + Timeout.timeout(1) {d.new_offset(n)} + end end def test__plus @@ -37,6 +44,13 @@ class TestDateArith < Test::Unit::TestCase assert_raise(e) do DateTime.new(2000,2,29) + Time.mktime(2000,2,29) end + n = Rat.new + assert_raise(e) do + Timeout.timeout(1) {Date.new(2000,2,29) + n} + end + assert_raise(e) do + Timeout.timeout(1) {DateTime.new(2000,2,29) + n} + end end def test__minus |