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 | f500faaaee55a23ea305ab8a91f3ee419c3b6ee5 (patch) | |
tree | 33d64e7b7cca126039bca7085eed290d2da8b31b /test/ruby/test_time.rb | |
parent | bb85a01113cbfe3b8d4f42322f5ca78b29a64420 (diff) | |
download | ruby-f500faaaee55a23ea305ab8a91f3ee419c3b6ee5.tar.gz |
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/test_time.rb')
-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 |