diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-21 12:06:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-21 12:06:40 +0000 |
commit | 5518b5c21a2168e45aa2382344583178cbb83c13 (patch) | |
tree | 33d64e7b7cca126039bca7085eed290d2da8b31b /test/ruby | |
parent | 33e8eef020018693e93e5df85655a8e8e0042d69 (diff) |
time.c: refine num_exact error message
* time.c (num_exact): show the original argument when conversion
failed, instead of intermediate nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_time.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 60bed87c9c..d3a8645024 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -1089,4 +1089,14 @@ class TestTime < Test::Unit::TestCase t = Time.utc(2017, 1, 1, 1, 0, 0).getlocal("-05:00") assert_equal("366", t.strftime("%j")) end + + def test_num_exact_error + bad = EnvUtil.labeled_class("BadValue").new + x = EnvUtil.labeled_class("Inexact") do + def to_s; "Inexact"; end + define_method(:to_int) {bad} + define_method(:to_r) {bad} + end.new + assert_raise_with_message(TypeError, /Inexact/) {Time.at(x)} + end end |