From 5518b5c21a2168e45aa2382344583178cbb83c13 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 21 Dec 2016 12:06:40 +0000 Subject: 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 --- test/ruby/test_time.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby/test_time.rb') 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 -- cgit v1.2.3